﻿

function BookHotel(){

var fmonth = getObj("arrivalMonthYear").value.substring(4,6);
        var tmonth = getObj("departureMonthYear").value.substring(4,6);
        if (fmonth.substring(0,1) == "0"){
			
            fmonth = fmonth.substring(1,2);
			
         }
         fmonth = parseInt(fmonth)+1;
        if (tmonth.substring(0,1) == "0"){
           tmonth = tmonth.substring(1,2);
		  
         }
		  tmonth = parseInt(tmonth)+1;
    
		
		
		
//		 iRet = window.open("http://www.daysinn.com/DaysInn/control/Booking/check_avail?advancedSearch=false"+
//		 "&entry_source=&brandCode=DI%2CHJ%2CKG%2CRA%2CSE%2CTL%2CBH%2CMT"+
//		"&checkInDate="+ fmonth +"/"+getObj("arrivalDay").value+
//		"&checkOutDate="+ tmonth +"/"+getObj("departureDay").value+
//		"&numberRooms=" +getObj("rooms").value+
//		"&numberAdults="+getObj("nadult").value+
//		"&numberBigChildren="+getObj("bigchild").value+
//		"&numberChildren="+getObj("nchild").value+
//		"&useWRPoints=false"+
//	    "&rate="+getObj("srp").value+
//		"&__rate=SRB&promotionCode=&corporateCode=&cid=&affilid=&partnerid=&iataNumber="+
//		"&areaCode=101J&searchWithinMiles=50&areaType=1&destination=Bonnyville&state=AB&country=CA&id=14345&propBrandId=DI&tab=tab2&resetCheckAvailMod=true" );
		
		
		
	
		iRet = window.open("http://www.daysinn.com/DaysInn/control/Booking/check_avail?advancedSearch=false&entry_source="+
		"&brandCode=DI%2CHJ%2CKG%2CRA%2CSE%2CTL%2CBH%2CMT"+
		"&checkInDate="+ fmonth +"/"+getObj("arrivalDay").value+
		"&checkOutDate="+ tmonth +"/"+getObj("departureDay").value+
		"&numberRooms=" +getObj("rooms").value+
		"&numberAdults="+getObj("nadult").value+
		"&numberBigChildren="+getObj("bigchild").value+
		"&numberChildren="+getObj("nchild").value+
		"&useWRPoints=false"+
		"&rate="+getObj("srp").value+
		"&__rate=SRB&promotionCode=&corporateCode=&cid=&affilid=&partnerid=&iataNumber="+
		"&areaCode=101J&searchWithinMiles=50&areaType=1&destination=Bonnyville&state=AB&country=CA&id=14345&propBrandId=DI&tab=tab2&resetCheckAvailMod=true");		
		
		 SendMail();
		

}

function setMenu(menuId)
{
	document.getElementById(menuId).id="current";
}



    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 SendMail()
    {  
    	

              
        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",RelativePath()+ "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." );
		}
	 }
    }
   