//----function for using ajax-----------
var xmlHttp

function checkCity(dr_id)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url=baseurl1+"ajax/checkcity.php"
url=url+"?dr_id="+dr_id
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function checkRoom(roomID)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url=baseurl+"ajax/room.php"
url=url+"?roomID="+roomID
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged1 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function showLokasi(cara,sykt){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	var url=baseurl1+"ajax/lokasi.php"
	url=url+"?ID="+cara
	url=url+"&syID="+sykt
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=lokasiStateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

var calCan

function showCal(calCanr,mon,year,ref){ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
 		alert ("Browser does not support HTTP Request")
 		return
 	}
	
	calCan = calCanr
	
	var url="cal.php"
	url=url+"?mon="+mon
	url=url+"&year="+year
	url=url+"&ref="+ref
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=calStateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}


function stateChanged() 
{ 

 if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 {
	//document.getElementById("loadname1").style.display="block";
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	document.getElementById("showCity").innerHTML=xmlHttp.responseText
	
	 
	//  document.getElementById("showcust").innerHTML="";
	 
	 //document.getElementById("loadname1").style.display="none";
 } 

}

function stateChanged1() 
{ 

 if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 {
	//document.getElementById("loadname1").style.display="block";
 }

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	 document.getElementById("DivShowRoom").innerHTML=xmlHttp.responseText
	 
	 
	//  document.getElementById("showcust").innerHTML="";
	 
	// document.getElementById("loadname1").style.display="none";
 } 

}

function lokasiStateChanged() 
{ 

	if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 	{
	//document.getElementById("loadname1").style.display="block";
 	}

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{ 
	 document.getElementById("DivShowLokasi").innerHTML=xmlHttp.responseText
	 
	//  document.getElementById("showcust").innerHTML="";
	 
	// document.getElementById("loadname1").style.display="none";
	} 
}

function calStateChanged() 
{ 

	if (xmlHttp.readyState==1 || xmlHttp.readyState==2)
 	{
	document.getElementById(calCan).innerHTML="loading..";
 	}

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 	{ 
	 document.getElementById(calCan).innerHTML=xmlHttp.responseText
	 
	//  document.getElementById("showcust").innerHTML="";
	 
	// document.getElementById("loadname1").style.display="none";
	} 
}


//this function for validate the browser for AJAX support
function GetXmlHttpObject()
{
var xmlHttp;
try
 {
	 
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

 }
 catch(e)
 {
  try
  {
	  //alert("b");
   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch(oc)
  {
	  
   xmlHttp = null;
  }
 }
 //Creating object of XMLHTTP in Mozilla and Safari 
 if(!xmlHttp) 
 {
  xmlHttp = new XMLHttpRequest();
 }

return xmlHttp;
}
