var xmlHttp
function getCity(str,sz){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="getcity.php"
	url=url+"?q="+str+"&sz="+sz
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 		document.getElementById("citydiv").innerHTML=xmlHttp.responseText 
 	} 
}


//GET HOTELS

function getHotels(ci,co,country,city,rooms,inicio,adults){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="getHotels.php"
	url=url+"?ci="+ci+"&co="+co+"&country="+country+"&city="+city+"&rooms="+rooms+"&start="+inicio+"&adults="+adults
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=getHotelHandler 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function getHotelHandler() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 		document.getElementById("PHPDATA").innerHTML=xmlHttp.responseText 
 	} 
}

//GET SUITES
function getSuites(ci,co,country,city,rooms,inicio,adults,searchSuites){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="getSuites.php"
	url=url+"?ci="+ci+"&co="+co+"&country="+country+"&city="+city+"&rooms="+rooms+"&start="+inicio+"&adults="+adults+"&searchSuites="+searchSuites
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=getHotelHandler 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function getHotelHandler() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 		document.getElementById("PHPDATA").innerHTML=xmlHttp.responseText 
 	} 
}
//
//LOGIN
function checkLogin(email,pass,donde){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url="checkLogin.php"
	url=url+"?u="+email+"&p="+pass+"&donde="+donde
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=loginHandler 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function loginHandler() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 	
		if((xmlHttp.responseText=="https://www.centralamericahotelrooms.com/checkOut.php")||(xmlHttp.responseText=="https://www.centralamericahotelrooms.com/myaccount.php")){
			window.location = xmlHttp.responseText 
		}else{
 			document.getElementById("LOGINDIV").innerHTML=xmlHttp.responseText 
			
		}
 	} 
}

function showTR(cualtr){
	switch(cualtr){
		case "1":
			path = document.getElementById('rowroom2')
			path.style.display = "none";
			path = document.getElementById('rowroom3')
			path.style.display = "none";
			path = document.getElementById('rowroom4')
			path.style.display = "none";
			path = document.getElementById('rowroom5')
			path.style.display = "none";
		break;
		case "2":
			if((browserName == "Firefox")||(browserName == "Safari")){
				path = document.getElementById('rowroom2')
				path.style.display = "table-row";
			}
			if(browserName == "Internet Explorer"){
				path = document.getElementById('rowroom2')
				path.style.display = "block";
			}
			path = document.getElementById('rowroom3')
			path.style.display = "none";
			path = document.getElementById('rowroom4')
			path.style.display = "none";
			path = document.getElementById('rowroom5')
			path.style.display = "none";
		break;
		case "3":
			if((browserName == "Firefox")||(browserName == "Safari")){
				path = document.getElementById('rowroom2')
				path.style.display = "table-row";
				path = document.getElementById('rowroom3')
				path.style.display = "table-row";
			}
			if(browserName == "Internet Explorer"){
				path = document.getElementById('rowroom2')
				path.style.display = "block";
				path = document.getElementById('rowroom3')
				path.style.display = "block";
			}
			path = document.getElementById('rowroom4')
			path.style.display = "none";
			path = document.getElementById('rowroom5')
			path.style.display = "none";
		break;
		case "4":
			if((browserName == "Firefox")||(browserName == "Safari")){
				path = document.getElementById('rowroom2')
				path.style.display = "table-row";
				path = document.getElementById('rowroom3')
				path.style.display = "table-row";
				path = document.getElementById('rowroom4')
				path.style.display = "table-row";
			}
			if(browserName == "Internet Explorer"){
				path = document.getElementById('rowroom2')
				path.style.display = "block";
				path = document.getElementById('rowroom3')
				path.style.display = "block";
				path = document.getElementById('rowroom4')
				path.style.display = "block";
			}
			path = document.getElementById('rowroom5')
			path.style.display = "none";
		break;
		case "5":
			if((browserName == "Firefox")||(browserName == "Safari")){
				path = document.getElementById('rowroom2')
				path.style.display = "table-row";
				path = document.getElementById('rowroom3')
				path.style.display = "table-row";
				path = document.getElementById('rowroom4')
				path.style.display = "table-row";
				path = document.getElementById('rowroom5')
				path.style.display = "table-row";
			}
			if(browserName == "Internet Explorer"){
				path = document.getElementById('rowroom2')
				path.style.display = "block";
				path = document.getElementById('rowroom3')
				path.style.display = "block";
				path = document.getElementById('rowroom4')
				path.style.display = "block";
				path = document.getElementById('rowroom5')
				path.style.display = "block";
			}
		break;
	}
}

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;
}
function showdiv(){
	path = document.getElementById("editForm")
	path.style.display = "block";
}
function hidediv(){
	path = document.getElementById("editForm")
	path.style.display = "none";
}
function showroomsdetails(cual){
	path = document.getElementById(cual)
	path.style.display = "block";
}
function hideroomdetails(cual){
	path = document.getElementById(cual)
	path.style.display = "none";
}
function showchangesearch(cual){
	path = document.getElementById('changesearch')
	path.style.display = "block";
}
function hidechangesearch(cual){
	path = document.getElementById('changesearch')
	path.style.display = "none";
}
function showreviews(cual){
	path = document.getElementById('addreview')
	path.style.display = "block";
}
function hidereviews(cual){
	path = document.getElementById('addreview')
	path.style.display = "none";
}