var xmlHttp;
var HtmlTagId;
//------AJAX------AJAX------AJAX------AJAX------AJAX------AJAX------

function GetStateVal(tagid,cid,controlid,width)
{ 
	
	HtmlTagId=tagid;
	
	if (document.getElementById("loadflag").value == "false")
	{
		document.getElementById(HtmlTagId).innerHTML="<img src='images/loading.gif' hspace=0 vspace=0 border=0>" + document.getElementById(HtmlTagId).innerHTML;
		document.getElementById("loadflag").value = "true";
	}
	
	var url="GetCity.aspx?sid="+ Math.random() +"&countryid="+ cid +"&controlid="+ controlid +"&width="+ width +"&CityText=" + document.getElementById("txtcitytext").value;
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("Get", url , true);
	xmlHttp.send(null);
} 
function GetStateVal1(tagid,cid,controlid,width)
{ 
	
	
	HtmlTagId=tagid;
	
	if (document.getElementById("loadflag").value == "false")
	{
		document.getElementById(HtmlTagId).innerHTML="<img src='images/loading.gif' hspace=0 vspace=0 border=0>" + document.getElementById(HtmlTagId).innerHTML;
		document.getElementById("loadflag").value = "true";
	}
	
	var url="GetState.aspx?sid="+ Math.random() +"&countryid="+ cid +"&controlid="+ controlid +"&width="+ width +"&CityText=" + document.getElementById("txtcitytext").value;
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("Get", url , true);
	xmlHttp.send(null);
} 
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(HtmlTagId).innerHTML=xmlHttp.responseText;
		document.getElementById("loadflag").value = "false";
	} 
} 

function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null;
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This page doesn't work in Opera") 
		return; 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP";
		}
		try
		{ 
			
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler ;
			return objXmlHttp;
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return;
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler;
		return objXmlHttp;
	}
} 


function ValidUser()
{
	if (emptyField(document.getElementById("txtLoginId")))
	{
		alert('Please enter User Name');
		document.getElementById("txtLoginId").focus();
		document.getElementById("txtLoginId").select();
		return false;
	}
	if (emptyField(document.getElementById("txtPwd")))
	{
		alert('Please enter Password');
		document.getElementById("txtPwd").focus();
		document.getElementById("txtPwd").select();
		return false;
	}
}
function ValidUserLogin()
{
	if (emptyField(document.getElementById("Login1_txtLoginId")))
	{
		alert('Please enter User Name');
		document.getElementById("Login1_txtLoginId").focus();
		document.getElementById("Login1_txtLoginId").select();
		return false;
	}
	if (emptyField(document.getElementById("Login1_txtPwd")))
	{
		alert('Please enter Password');
		document.getElementById("Login1_txtPwd").focus();
		document.getElementById("Login1_txtPwd").select();
		return false;
	}
}

function SelectCountryAndCityUserPreview()
{
/*if (document.getElementById("Preview1_ddlCountry").value == 0)
	{
		alert('Please Select Country.');
		//document.getElementById("txtAge").focus();
		//document.getElementById("txtAge").select();
		return false;
	}
	if (document.getElementById("Preview1_ddlCity").value == 0)
	{
		alert('Please Select City.');
		//document.getElementById("txtAge").focus();
		//document.getElementById("txtAge").select();
		return false;
	}*/
}



function chkforDropRent()
{
	var minrent;
	minrent=parseInt(document.getElementById("ddlMinRent").value);
	
	var maxrent;
	maxrent=parseInt(document.getElementById("ddlMaxRent").value);
	
	if (minrent>maxrent)
	{
		alert('Min Rent can not greater than Max Rent');
		return false;
	}

	var minage;
	minage=parseInt(document.getElementById("ddlMinAge").value);
	
	var maxage;
	maxage=parseInt(document.getElementById("ddlMaxAge").value);
	
	if (minage>maxage)
	{
		alert('Min Age can not greater than Max Age');
		return false;
	}


}

function chkforAge()
{
	var minage;
	minage=parseInt(document.getElementById("ddlMinAge").value);
	
	var maxage;
	maxage=parseInt(document.getElementById("ddlMaxAge").value);
	
	if (minage>=maxage)
	{
		alert('Min Age can not greater than Max Age');
		return false;
	}


}


function chkforRent()
{
	var minrent;
	minrent=parseInt(document.getElementById("Search1_ddlMinRent").value);
	
	var maxrent;
	maxrent=parseInt(document.getElementById("Search1_ddlMaxRent").value);
	
	if (minrent>maxrent)
	{
		alert('Min Rent can not greater than Max Rent');
		return false;
	}


	var minage;
	minage=parseInt(document.getElementById("Search1_ddlMinAge").value);

	var maxage;
	maxage=parseInt(document.getElementById("Search1_ddlMaxAge").value);
	
	if (minage>maxage)
	{
		alert('Min Age can not greater than Max Age');
		return false;
	}
}


function chkforDropAgeHave()
{

	var minage;
	minage=parseInt(document.getElementById("SearchHaveRoom1_ddlMinAge").value);

	var maxage;
	maxage=parseInt(document.getElementById("SearchHaveRoom1_ddlMaxAge").value);
	
	if (minage>maxage)
	{
		alert('Min Age can not greater than Max Age');
		return false;
	}


	if (emptyField(document.getElementById("SearchHaveRoom1_txtRent")))
	{
		alert('Please enter Rent.');
		document.getElementById("SearchHaveRoom1_txtRent").focus();
		document.getElementById("SearchHaveRoom1_txtRent").select();
		return false;
	}
	
	if (!isNum(document.getElementById("SearchHaveRoom1_txtRent").value))
	{
		alert('Please enter Numeric Rent.');
		document.getElementById("SearchHaveRoom1_txtRent").focus();
		document.getElementById("SearchHaveRoom1_txtRent").select();
		return false;
	}
}



function ValidSearchForRoomInASCX()
{
	/*alert('hi');
	if (document.getElementById("Preview1_ddlCountry").value == 0)
	{
		alert('Please Select Country.');
		return false;
	}
	if (document.getElementById("Preview1_ddlCity").value == 0)
	{
		alert('Please Select City.');
		return false;
	}
	
					
	document.thisform.HModel.value=document.getElementById("ddlCity").value;
	*/
				
}

function ValidSearchForRoom()
{
	/*if (document.getElementById("ddlCountry").value == 0)
	{
		alert('Please Select Country.');
		return false;
	}
	if (document.getElementById("ddlCity").value == 0)
	{
		alert('Please Select City.');
		return false;
	}*/
					
	document.thisform.HModel.value=document.getElementById("ddlCity").value;
	document.thisform.hdState1.value=document.getElementById("ddlState").value;
	//alert(document.thisform.hdState1.value);
}

function ValidSearchForPost()
{

	document.thisform.HModel.value=document.getElementById("ddlCityForPost").value;
	document.thisform.hdState1.value=document.getElementById("ddlState1").value;
}

