/************************************************************************************************** 
* Ajax Function, Start 
**************************************************************************************************/
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
/************************************************************************************************** 
* Ajax Function, End
**************************************************************************************************/

function checkUncheckAll(chk){
	if(document.frm.checkBox.checked==false){
		if(chk.length==undefined){
			chk.checked=false;
		}
		else{
			for(i=0;i<chk.length;i++)
			chk[i].checked=false;
		}
	}
	else{
		if(chk.length==undefined){
			chk.checked=true;
		}
		else{
			for(i=0;i<chk.length;i++)
			chk[i].checked=true;
		}
	}
}

/************************************************************************************************** 
* Functtion to get city, State 
**************************************************************************************************/
function getCity(arg){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url="getcity.php";
	url=url+"?state_id="+arg;
	xmlHttp.onreadystatechange=
		function showCity(){
			if (xmlHttp.readyState==4){ 
				document.getElementById('cityDiv').innerHTML=xmlHttp.responseText;
			}
		};		
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}
/************************************************************************************************** 
* Functtion to get city, End  
**************************************************************************************************/
/************************************************************************************************** 
* Function to check all checkbox, Start
**************************************************************************************************/
function checkAll(chk){ 
	if(chk.length==undefined){
		chk.checked=true;	
	} else {
		for (i = 0; i < chk.length; i++)
		chk[i].checked = true ;
	}
} 
/************************************************************************************************** 
* Function to check all checkbox, End
**************************************************************************************************/

/************************************************************************************************** 
* Function to Uncheck all checkbox, Start
**************************************************************************************************/
function unCheckAll(chk){ 
	if(chk.length==undefined){
		chk.checked=false;	
	} else {
		for (i = 0; i < chk.length; i++) 
		chk[i].checked = false;
	} 
}

function passwordavailable() {
	var password=document.getElementById("Password").value;
	if(password){
		var url="getpassword.php?Password="+password;
		xmlHttp=GetXmlHttpObject();
		xmlHttp.onreadystatechange=statChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	} else {
		document.getElementById("passworddiv").innerHTML="";
	}
}
function statChanged() {
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	{
		if(xmlHttp.responseText==0 ) {
			document.getElementById("passworddiv").innerHTML="Password is not valid.";
			document.getElementById("passworddiv").style.display="block";
			document.getElementById("Password").focus();
		}
		if(xmlHttp.responseText==1 ) {
			document.getElementById("passworddiv").innerHTML="Password is valid.";
			document.getElementById("passworddiv").style.display="block";
		}
	} else {
			document.getElementById("passworddiv").style.display="none";
	}
}


/************************************************************************************************** 
* Functtion to get subcategory, Start  
**************************************************************************************************/
function gethoteltype(city){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="gethoteltype.php";
	url=url+"?city_id="+city;
	xmlHttp.onreadystatechange=showSubCategory;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showSubCategory(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("hoteldivs").innerHTML=xmlHttp.responseText;
	}
}
/************************************************************************************************** 
* Functtion to get subcategory, End  
**************************************************************************************************/
/************************************************************************************************** 
* Functtion to get hoteltype, Start  
**************************************************************************************************/
function gethoteltypes(city){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="gethoteltypes.php";
	url=url+"?city_id="+city;
	xmlHttp.onreadystatechange=showSubCategorys;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showSubCategorys(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("hoteldiv").innerHTML=xmlHttp.responseText;
	}
}
/************************************************************************************************** 
* Functtion to get hoteltype, End  
**************************************************************************************************/

/************************************************************************************************** 
* Functtion to get hotel, Start  
**************************************************************************************************/
function gethotel(hotel){
	vars=document.form.city.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  	alert ("Your browser does not support AJAX!");
  		return;
  	}
	var url="gethotel.php";
	url=url+"?hotel="+hotel+"& city="+vars;
	xmlHttp.onreadystatechange=showhotel;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function showhotel(){ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("hoteldivi").innerHTML=xmlHttp.responseText;
	}
}

