// JavaScript Document
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function checkout_validation(val,chkin,h_i,r) {		
		var strURL="checkout_validation.php?val="+val+"&cin="+chkin+"&hi="+h_i+"&rid="+r;
		document.getElementById("room").value="";
		var req = getXMLHTTP();
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('checkoutbox').style.visibility="visible";
						document.getElementById('checkoutbox').innerHTML=req.responseText;	
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	function available_validation(val,chkin,chout,h_i,r) {		
		var strURL="room_available_validation.php?val="+val+"&cin="+chkin+"&co="+chout+"&hi="+h_i+"&rid="+r;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					if(req.responseText!="")
					{
					document.getElementById('avrooms').style.visibility="visible";
					}
					else
					{
						document.getElementById('avrooms').style.visibility="hidden";
					}
						document.getElementById('avrooms').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	function guest_validation(gnum,totroom,h_i,rid,chkin,chout) {		
		var strURL="room_guest_validation.php?val="+gnum+"&tr="+totroom+"&hi="+h_i+"&rid="+rid+"&cin="+chkin+"&co="+chout;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {	
					if(req.responseText!="")
					{
					document.getElementById('avguest').style.visibility="visible";
					}
					else
					{
						document.getElementById('avguest').style.visibility="hidden";
					}
						document.getElementById('avguest').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
