function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}
var httpr= getXMLHTTPRequest();
var http = getXMLHTTPRequest();
var httpg= getXMLHTTPRequest();
var idname;
function sijan()
{
alert('hello');
}

function getServerTime() {
  var myurl = 'book.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&lat="+document.sendform.lat.value+"&lng="+document.sendform.lng.value;
  httpr.open("GET", modurl, true);
  httpr.onreadystatechange = useHttpResponse;
  httpr.send(null);
}
function enterVisa() {
  var myurl = 'visa.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&visano="+document.hotelbook.visano.value+"&do=insert";
  httpr.open("GET", modurl, true);
  httpr.onreadystatechange = useHttpResponse;
  httpr.send(null);
}

function findPlace() {
  var myurl = 'ajax.php';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"?rand="+myRand+"&place="+document.givCommandPlace.place.value+"&m=findplace";
  httpr.open("GET", modurl, true);
  httpr.onreadystatechange = useHttpResponseForPlace;
  httpr.send(null);
}
function useHttpResponseForPlace(){

if (httpr.readyState == 4) {
   if(httpr.status == 200) {
     
      
	   var txt=httpr.responseText;
	   return txt;
	   
	   }
	   }
	   
	   
    





}


function getServerFile(urlinput,idnam) {
  var myurl = urlinput;
  idname=idnam;
  myRand1 = parseInt(Math.random()*999999999999999);
  var modurl1 = myurl+"&rand="+myRand1;
  http.open("GET", modurl1,true);
  http.onreadystatechange = useHttpResponseforfile;
  http.send(null);
}

function useHttpResponseforfile() {
//idname="showtime";
   if (http.readyState == 4) {
   if(http.status == 200) {
     	   var txt=http.responseText;
	   document.getElementById(idname).innerHTML = txt;
	   
    }
	else document.getElementById(idname).innerHTML = 'processing ';
  } 
  else if(http.readyState==0) {
  document.getElementById(idname).innerHTML = 'state0';
  }
  else if(http.readyState==1) {
  document.getElementById(idname).innerHTML = 'state1';
  }
  else if(http.readyState==2) {
  document.getElementById(idname).innerHTML = 'state2';
  }
  else if(http.readyState==3) {
  document.getElementById(idname).innerHTML = 'state3';
  }
}
function closediv(divname)
{
 document.getElementById(divname).innerHTML='';

}
function useHttpResponse() {
   if (httpr.readyState == 4) {
   if(httpr.status == 200) {
     // var timeValue = http.responseXML.getElementsByTagName("timenow")[0];
      //document.getElementById('showtime').innerHTML = timeValue.childNodes[0].nodeValue;
	   var txt=httpr.responseText;
	   document.getElementById('showtime').innerHTML = txt;
	   
    }
  } else {
  document.getElementById('showtime').innerHTML = 'wait';
  }
}
function getResponseOfBook(){
var myurl = 'responseServer.php';
  myRand = parseInt(Math.random()*999999999999999);
  var arrivaltime = document.hotelbook.year.value+document.hotelbook.month.value+document.hotelbook.dt.value;
  //var thisLatLng=marker.getLatLng();
  var sendurl = myurl+"?rand="+myRand+"&do=insert&arrivaltime="+arrivaltime+"&daystostay="+document.hotelbook.days.value+"&roomtype="+document.hotelbook.room.value+"&lat="+document.hotelbook.lat.value+"&lng="+document.hotelbook.lng.value;
  http.open("GET", sendurl, true);
  http.onreadystatechange = useHttpResponser;
  http.send(null);

}
function useHttpResponser() {
   if (http.readyState == 4) {
   if(http.status == 200) {
     // var timeValue = http.responseXML.getElementsByTagName("timenow")[0];
      //document.getElementById('showtime').innerHTML = timeValue.childNodes[0].nodeValue;
	   var txt=http.responseText;
	   document.getElementById('showtime').innerHTML = txt;
	   
    }
  } else {
  document.getElementById('showtime').innerHTML = 'wait';
  }
}


function useHttpResponseX()
{
	if(http.readyState==4){
	if(http.status==200){
	var timeValue=http.responseXML.getElementsByTagName("timenow")[0];
	document.getElementById('showtime').innerHTML=timeValue.childNodes[0].nodeValue;
	}
	}
	else{
	document.getElementById('showtime').innerHTML="wait";
	}
}