/*******************************************/
var forgotVisibilityOption = "visible";
//********************************
//**** 
//********************************
function HideForgotPassordsFields()
{
	var forgotMessage = document.getElementById("WucMainLogin1_forgotMessage");
	forgotMessage.style.visibility = forgotVisibilityOption;
	forgotMessage = document.getElementById("WucMainLogin1_forgotPasswordFields");
	forgotMessage.style.visibility = forgotVisibilityOption;
	forgotVisibilityOption = "visible";
	
}
//
// Show or hide forgot passwordsfields
//
function ShowForgotPasswordFileds()
{
	var forgotMessage = document.getElementById("WucMainLogin1_forgotMessage");
	forgotMessage.style.visibility = forgotVisibilityOption;
	forgotMessage = document.getElementById("WucMainLogin1_forgotPasswordFields");
	forgotMessage.style.visibility = forgotVisibilityOption;
	if(forgotVisibilityOption == "visible")
	{
		forgotVisibilityOption = "hidden";
	}
	else
	{
		forgotVisibilityOption = "visible";
	}
}

//**************************************************************

function CheckBrowser()
{
	try
	{
		var nav = [];
		nav.type = navigator.appVersion.split(';')[1].split(' ');
		nav.name = nav.type[1];
		nav.version = nav.type[2];
		var loginFaild = true;
		if (nav.name != 'MSIE') loginFaild = false; 
		if (nav.version < 5.5) loginFaild = false; 
		return loginFaild;
	}
	catch(e) 
	{
		alert(e.description);
	}
}//End function CheckBrowser

   
	function isnull(sValue) 
	{
					sValue = String(sValue);
		return (	sValue == '' || sValue == 'null' || sValue == 'undefined'); 
	}
	
	function trim(sValue,sDefault)
	{
			var trm = CStr(sValue);
			var dfl = CStr(sDefault);
	
		trm = trm.replace(/(^\s*)|(\s*$)/g, ""); 
		dfl = dfl.replace(/(^\s*)|(\s*$)/g, "");
	
		return trm==""?dfl:trm;
	}
	//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	function CInt(vValue,vDefault)
	{
		var str	= trim(vValue);
		var strd = trim(vDefault);

			var intg = parseInt(str,10);
			var intd = parseInt(strd,10);

		intd = (isNaN(intd)?0:intd);

		return (isNaN(intg)?intd:intg);
	} 	 
	function CStr(vValue,vDefault)
	{
			vDefault += "";
		if(vDefault	== "undefined") vDefault = "";
		if(vDefault	== "null")      vDefault = ""; 
		
			vValue	+= "";
		if(vValue	== "undefined") return vDefault;
		if(vValue	== "null")      return vDefault;
		
		return vValue;
	}
	
//*****************************************************		
//***************Content management *******************

//*********************************************
var arr = new Array();

function LoadContent(content)
{
	arr = content.split(':');
}

function ShowMessage(index)
{
	alert(arr[index]);
}

/*
** Default page Ajax functionality
*/
function SetCategoryAndSubCategory(cat, subcat)
{
	// added by gen0k on 12 Dec 2006
	if (cat!=6)
	{
		location.href="wfADViewer.aspx?cat="+cat+"&subcat="+subcat;
	}
	else
	{
		location.href="wfADViewer.aspx?cat=6&subcat=-1&service_group=all&service_type=-1";
	}
	return;
	
	//_Default.SetCategoryAndSubCategory(cat, subcat, SetCategoryFromClient_callback);
}

//********************************
//**** 
//********************************
function SetCategoryFromClient_callback(responseSelect)
{
	window.location.href = "wfADViewer.aspx";
}

//********************************
//**** 
//********************************
function SetCountryFromClient_callback(responseSelect)
{
	window.location.href = "default.aspx";
}

function ChooseAdvertType(categoryId)
{
	window.location.href = "AddAdvert.aspx?category=" + categoryId;
}
function CarManufacturer_SelectedIndexChanged(ddl_manufactorers)
{
	if (typeof(wfADViewer)!='undefined')
	{
		var selectedManufacturerID = ddl_manufactorers[ddl_manufactorers.selectedIndex].value;
		wfADViewer.CarManufacturer_SelectedIndexChanged(selectedManufacturerID,CarManufacturer_SelectedIndexChanged_callback);
	}
}
function CarManufacturer_SelectedIndexChanged_callback(response)
{
	var ddl_models = document.getElementById("searchFormCar_ddl_model");
	//ddl_models.length=0;
	var object = response.value;
	for (i = 1; i <= object.length; i++) 
	{
			ddl_models.options[i] = new Option(object[i-1].Value);
			ddl_models.options[i].value = object[i-1].Key; 
	}	
	//ddl_models.selectedIndex=0;
}


function ChildrenType_SelectedIndexChanged(ddl_subcategory)
{
	if (typeof(wfADViewer)!='undefined')
	{
		var selectedSubCategoryID = ddl_subcategory[ddl_subcategory.selectedIndex].value;
		wfADViewer.ChildrenType_SelectedIndexChanged(selectedSubCategoryID,ChildrenType_SelectedIndexChanged_callback);
	}
}
function ChildrenType_SelectedIndexChanged_callback(response)
{
	var ddl_type = document.getElementById("searchFormChildren_ddl_type");
	ddl_type.length=0;
	var object = response.value;
	for (i = 1; i <= object.length; i++) 
	{
			ddl_type.options[i] = new Option(object[i-1].Value);
			ddl_type.options[i].value = object[i-1].Key; 
	}	
	//ddl_models.selectedIndex=0;
}

var oldColor;
function switchColor(object, color, cells)
{
	//alert(object.children[0].style.backgroundColor);
	oldColor = object.children[0].style.backgroundColor;
	
	for(var cellIndex = 0; cellIndex < cells; cellIndex ++)
	{
		object.children[cellIndex].style.backgroundColor = color;
	}
}

/*******************************************/
/* Advert RealEstate ***********************/
function MaklerDecision()
{
	document.getElementById("maklerDvice").style["visibility"] = "hidden";
	document.getElementById("maklerDecision").style["visibility"] = "visible";
	document.getElementById("maklerDecisionValue").value = "true";
}

/*
function Trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
	return "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
	}
	else
	{
		return TRIM_VALUE;
	}
} 

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} 
	return strTemp;

} 

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} 
	return strTemp;
}
*/
function SetCountry(country)
{
	_Default.SetCountry(country, SetCountryFromClient_callback);
}
