// JavaScript Document



function bookdetail(rid,hid)
	{				
		document.getElementById("hid").value=hid;
		document.getElementById("rid").value=rid;
		
		document.frmbook.submit();
	}
	
	function bookdetail_hd(rid,hid)
	{			
	   
		document.getElementById("hid").value=hid;
		document.getElementById("rid").value=rid;
		
		document.frmbook.submit();
	}
	
  function getcon()
	{
		var num = document.getElementById("txtcountry").selectedIndex;
	    var nd= document.getElementById("txtcountry").options[num].text;
		document.getElementById("txtcountry").options[num].value=nd;
    }
function filterrate(sid,id)
  {     
	var sidtemp=id + sid;
	//alert (sidtemp);
	  if (document.getElementById(sid).checked)
	  {
		 document.getElementById(sidtemp).value=1;		
		 showfilter(); 
	 } 
	  else
	  {
		  document.getElementById(sidtemp).value=0;
		  showfilter();
	  }
  }

function filterarea(areaname,areaid)
  {
	  
	  var temparea="area" + areaid;
	
	  if (document.getElementById(areaname).checked)
	  {
		  document.getElementById(temparea).value=areaname;
		  showfilter();
	  }
	  else
	  {		  
		  document.getElementById(temparea).value=0;
		  showfilter();
	  }
  }
  
  function getminmax(minr,maxr)
  {
	  //alert (minr);
	  //alert (maxr);
	  document.getElementById("minval").value=minr;
	  document.getElementById("maxval").value=maxr;
      showfilter();
  }
     function moreincl(inclid,incl)
  {
	  //alert ("hi");
	  //alert (inclid);
	  //alert (incl);
	  inclid1="incl"+inclid;
	  	  
	  var temp='<a href="javascript:void(0)" onclick="lessincl('+ "'" + inclid + "'" + ','+ "'" + incl + "'" +')" style="text-decoration:none;">...Less</a>';
	 
	 document.getElementById(inclid1).innerHTML=incl + temp ;
  }

     function lessincl(inclid1,incl1)
  {
	  inclid2="incl"+inclid1;
	 
	  var incl2=incl1.substr(0,15);
	  
	  var temp='<a href="javascript:void(0)" onclick="moreincl('+ "'" + inclid1 + "'" + ','+ "'" + incl1 + "'" +')" style="text-decoration:none;">...More</a>';
		
	  document.getElementById(inclid2).innerHTML=incl2 + temp ;
		
  }


	 function showroom(hotn,id)

 {
	 		 
	 if (document.getElementById(hotn).style.display=="none")
	     {
			 var temp='<img src="images/Pick A Room.png" onclick="showroom(' + "'" + hotn + "'" + ',' + "'" + id + "'" + ')"/>';
		   
			  document.getElementById(id).innerHTML=temp;
			  document.getElementById(hotn).style.display="block";
		 }
	else
	   
	   {
var temp='<img src="images/Pick A Room1.png" onclick="showroom(' + "'" + hotn + "'" + ',' + "'" + id + "'" + ')"/>';
		   
		   document.getElementById(id).innerHTML=temp;
		   document.getElementById(hotn).style.display="none";
		}
 }
  
  
  
  
     function showdiv(id)
{
	
	id1=id+"1";
	id2=id+"2";
	document.getElementById(id1).style.display="block";
	//document.getElementById(id1).style.visibility="visible";
	document.getElementById(id2).style.display="block";
	//document.getElementById(id2).style.visibility="visible";
	document.getElementById(id).style.display="none";
	//document.getElementById(id).style.visibility="hidden";
}

     function hidediv(di)
{
	di=di.split('1');
	di=di[0];
	di1=di+"1";
	di2=di+"2";
	
	document.getElementById(di1).style.display="none";
	//document.getElementById(di1).style.visibility="hidden";
	document.getElementById(di2).style.display="none";
	//document.getElementById(di2).style.visibility="hidden";
	document.getElementById(di).style.display="block";
	//document.getElementById(di).style.visibility="visible";
}

/* For Popup */
	function toggle(div_id) 
{
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' )
	{	
	el.style.display = 'block';
	}
	else
	{
		el.style.display = 'none';
	}
}

    function blanket_size(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined')
	{
		viewportheight = window.innerHeight;
	} 
	else
	{
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight))
	{
		blanket_height = viewportheight;
	} 
	else 
	{
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		}
		else 
		{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-450;
	//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}



function window_pos(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-450;
	//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname)
{
	//alert("hi");
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

    function blanket_size(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined')
	{
		viewportheight = window.innerHeight;
	} 
	else
	{
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight))
	{
		blanket_height = viewportheight;
	} 
	else 
	{
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		}
		else 
		{
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	
	var blanket = document.getElementById('blanket-popup');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-400;
	//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}



function window_pos(popUpDivVar)
{
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;
	//150 is half popup's width
	popUpDiv.style.left = '340px';
	popUpDiv.style.top = '-120px';
}
function popup(windowname)
{
	//alert("hi");
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket-popup');
	toggle(windowname);		
}

/* For Popup */


/* Ajax Function for popup content */

	var xmlhttp;
function showdiv1(name)
{
	alert (name);	
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="hotel-popup.php";
url=url+"?name="+name;

xmlhttp.onreadystatechange=stateChangedhd;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChangedhd()
{
if (xmlhttp.readyState==4)
{
	if(xmlhttp.status == 200)
		{
			   var a = xmlhttp.responseText;
			   alert (a);
			   document.getElementById("popUpDiv").innerHTML=xmlhttp.responseText;	
			     popup('popUpDiv');		
		}
}


}
/* Ajax Function for popup content */

/* Ajax Function for login */

	var xmlhttp;
	var tempurl="";
	var tempkgid="";
function login()
{	
   
    
    tempurl=document.getElementById("url").value;
	//tempkgid=document.getElementById("pkgid").value;
		
	var username=document.getElementById("username").value;
	var pass=document.getElementById("pass").value;
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="login.php";
url=url+"?username="+username;
url=url+"&pass="+pass;

xmlhttp.onreadystatechange=stateChangedlgc;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChangedlgc()
{
if (xmlhttp.readyState==4)
{
	if(xmlhttp.status == 200)
		{
			  var a = xmlhttp.responseText;
			  var yes=a.indexOf('Y');
			  var no=a.indexOf('N');
		     
			   if (no>=0)
			   {	
			    document.getElementById("logwait").innerHTML='<img src="images/login.png" onclick="login(' + "'"+ tempurl +"'" +')" />';
		        document.getElementById("err").innerHTML= "Incorrect Username Or Password, Please try again";			               }
			 
			    if (yes>=0)
			   {
				  document.getElementById("logwait").innerHTML="<img src='images/login.gif' onclick='login()' />";
		          document.getElementById("err").innerHTML= "";	
				  
				  if (tempurl=="/saibless/hoteldetails.php?hname=Rama-International&hcity=Aurangabad")
				   { document.frmaebsreq.submit(); }
         	      else  if (tempurl=="/saibless/packagedetails.php?pid="+tempkgid)
				   { document.frmaebsreq1.submit(); }
         	      else
				  	{ window.location.reload(); }
			   }
			
		}
		
}

else
{
	document.getElementById("logwait").innerHTML="<img src='images/ajax-loader.gif' />";
}

}

/* Ajax Function for login */

/* Ajax Function for login-book */

	var xmlhttp;
function login_book()
{	
	var username=document.getElementById("username1").value;
	var pass=document.getElementById("pass1").value;
	
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="login.php";
url=url+"?username="+username;
url=url+"&pass="+pass;

xmlhttp.onreadystatechange=stateChangedlgcbook;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChangedlgcbook()
{
if (xmlhttp.readyState==4)
{
	if(xmlhttp.status == 200)
		{
			  var a = xmlhttp.responseText;
			  var yes=a.indexOf('Y');
			  var no=a.indexOf('N');
                
			   if (no>=0)
			   {	
			      document.getElementById("err1").innerHTML="Incorrect Username Or Password, Please try again";			               
			   }
			   
			   if (yes>=0)
			   {
				  document.getElementById("err1").innerHTML="";		
   			      document.frmbook.submit();			  
			   }
		}
		
}

else
{
	
}

}

/* Ajax Function for login-book */

function enter_login_book(e)
{
	if (e.keyCode==13)
	{
		login_book();
	}
}

function enter_login(e)
{
	if (e.keyCode==13)
	{
		login();
	}
}

function enter_reg(e)
{
	if (e.keyCode==13)
	{
		validateuserreg();
	}
}

function enter_reg_book(e)
{
	if (e.keyCode==13)
	{
		validateuserreg_book();
	}
}


/* Function Get GetXmlHttpObject */

	function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

/* Function Get GetXmlHttpObject */
/* Ajax Function for Filtering Hotel */
var xmlhttp;
function showfilter()
{
	  var star1=document.getElementById("1one-star").value;
	  var star2=document.getElementById("2two-star").value;
	  var star3=document.getElementById("3three-star").value;
	  var star4=document.getElementById("4four-star").value;
	  var star5=document.getElementById("5five-star").value;
	  var city=document.getElementById("city").value;
	  var areacount=document.getElementById("areacount").value;	
	  var minval= document.getElementById("minval").value;
	  var maxval= document.getElementById("maxval").value;
	  var noroom= document.getElementById("noroom").value;
	  var days= document.getElementById("days").value;
	  var ckin= document.getElementById("chin").value;
	  var ckout= document.getElementById("chout").value;
	  
	
	xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
  
var url="filterresult.php";
url=url+"?city="+city;
url=url+"&onestar="+star1; 
url=url+"&twostar="+star2; 
url=url+"&threestar="+star3;
url=url+"&fourstar="+star4; 
url=url+"&fivestar="+star5; 
url=url+"&areacount="+areacount; 
url=url+"&minval="+minval; 
url=url+"&maxval="+maxval; 
url=url+"&noroom="+noroom; 
url=url+"&days="+days; 
url=url+"&ckin="+ckin; 
url=url+"&ckout="+ckout; 

	for (i=0; i<areacount; i++)
	{
		var ttarea="area"+i;
		var  areaval=new Array();
		areaval[i]=document.getElementById(ttarea).value;
		url=url+"&areaval"+ i +"="+areaval[i]; 
	}
	
	
xmlhttp.onreadystatechange=stateChangehoteldata;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChangehoteldata()
{
if (xmlhttp.readyState==4)
{
	if(xmlhttp.status == 200)
		{
			  var a = xmlhttp.responseText;
			  //alert (a);
			  document.getElementById("information-div1").innerHTML=xmlhttp.responseText;	
			    	
		}
}
else
{
	       document.getElementById("information-div1").innerHTML= "<img src='images/ajax-loader1.gif' />";
}

}
/* Ajax Function for Filtering Hotel */


//////////// pagination
function getpage(pageNumber)
{
	var url = location.href ;
	var urlString = url.split( "&page=" );

	if( urlString[0].indexOf("?") < 0 )
	    urlString[0] = urlString[0] + "?" ;

	if( urlString[0].indexOf("&") < 0 )
	    urlString[0] = urlString[0] + "&" ;
	
	window.location = urlString[0] + "&page=" + pageNumber;
}

