﻿

function BookHotel(){



        var Arrdd=getObj("arrivalDay").value;
        var Arrmonth = getObj("arrivalMonthYear").value.substring(4,6);
        var Arryear = getObj("arrivalMonthYear").value.substring(0,4);
        
        var Depdd=getObj("departureDay").value;
        var Depmonth = getObj("departureMonthYear").value.substring(4,6);
        var Depyear = getObj("departureMonthYear").value.substring(0,4);
       
        if (Arrmonth.substring(0,1) == "0"){
			
            Arrmonth = Arrmonth.substring(1,2);
			Arrmonth = parseInt(Arrmonth)+1;
         }
         else
         {
         Arrmonth = parseInt(Arrmonth)+1;
         }
      
        if (Depmonth.substring(0,1) == "0"){
           Depmonth = Depmonth.substring(1,2);
		   Depmonth = parseInt(Depmonth)+1;
         }
         else
         {
            Depmonth = parseInt(Depmonth)+1;
         }

		iRet = window.open("http://www.choicehotels.ca/rooms/CN042?srp="+getObj("bestrate").value+"&checkin="+Arrdd+"-"+Arrmonth+"-"+Arryear+"&checkout="+Depdd+"-"+Depmonth+"-"+Depyear);
		
		
		//iRet = window.open("http://www.choicehotels.ca/en/rooms/CN042?checkout=27-2-2011&srp="+getObj("bestrate").value+"&checkin="+tdd+"-"+tmonth+"-"+tyear+"&rooms=1&adults=1&children=0&cid=374214");
		
SendBookMail();

}

function setMenu(menuId)
{
	document.getElementById(menuId).id="current";
}

       //////////////////////////////////////////Js Code for  Cookies///////////////////////////////////
    
        function set_cookie ( name, value)
            {  
              document.cookie = name + "=" + escape ( value );
            }
    
	    function Get_Cookie( name ) {
	    

	
	    var start = document.cookie.indexOf( name + "=" );
	    var len = start + name.length + 1;
	    if ( ( !start ) &&( name != document.cookie.substring( 0, name.length ) ) )
	    {
	    return null;
	    }
	    if ( start == -1 ) return null;
	    var end = document.cookie.indexOf( ";", len );
	    if ( end == -1 ) end = document.cookie.length;
	    return unescape( document.cookie.substring( len, end ) );
	    }
		        
        function delete_cookie ( cookie_name )
        {
          var cookie_date = new Date ( );  // current date & time
          cookie_date.setTime ( cookie_date.getTime() - 1 );
          document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
        }
    
   /////////////////////////////////////////////////////////////////////////////////////
   
   
   function RelativePathBook()
{

    // Remove any frames
//    if (top.location != self.location) {
//      top.location = self.location;
//    }

    var url = self.location.href;
    url = url.toLowerCase();
    var path = '';
    
    // determine the server   
    var local = 'localhost/';
    var server = 'server/';
    var live  = 'rodewayinnfallsview.com/';

    
    if(url.lastIndexOf(local) > 1)
        path = "http://localhost/RodewayInnFallsview/";
    else if(url.lastIndexOf(live) > 1)
        path = "http://www.rodewayinnfallsview.com/";
    
    return path; 
    
  
} 
   
   
   
	 var XmlHttp;    
     //Creating and setting the instance of appropriate XMLHTTP Request object to a “XmlHttp” variable  
     function CreateXmlHttp()
     {
           //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");

	      //Creating object of XMLHTTP in IE
	      try
	      {
		    XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	      }
	      catch(e) 
	      {
		    try
		    {
			    XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		    } 
		    catch(oc)
		    {
		        XmlHttp = null;
		    }
	      }
	      //Creating object of XMLHTTP in Mozilla and Safari 
	      if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	      {
		    XmlHttp = new XMLHttpRequest();
	      }
      }
    
  
    
    function SendBookMail()
    {   
   
        CreateXmlHttp();
       
            // If browser supports XMLHTTPRequest object
          if(XmlHttp)
          {  
      
        
	         //Setting the event handler for the response	  
	         XmlHttp.onreadystatechange = HandleResponseSendMail;  
             //Initializes the request object with GET (METHOD of posting), 
	         //Request URL and sets the request as asynchronous.
	         
	         XmlHttp.open("POST",RelativePathBook()+ "BookAjax.aspx",  true); 
	         this.XmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')                		
	         //Sends the request to server	       
	         XmlHttp.setRequestHeader("Connection", "close");  
	         
	         XmlHttp.send("Book=yes");    
           }   
     }


    function HandleResponseSendMail()
   { 
	// To make sure receiving response data from server is completed	
	if(XmlHttp.readyState == 4)
	{	 // To make sure valid response is received from the server, 200 means response received is OK
//		if(XmlHttp.status == 200)
//		{		  // alert('Thank you for contacting Perimeter Reservations'); 
// 	    }
//		else
//		{
//		  alert("There was a problem retrieving data from the server." );
//		}
	 }
    }
   
   
