﻿function BookHotel(page){
          getObj("selectHotelForm").target="_blank";	   		 
	    getObj("selectHotelForm").action=
"http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=61030&suppressSSLPopup=true&disablenav=true&sob=P508";
	SendMail(); 
}

  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 RelativePath()
{

    // 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  = 'bestwesternairportinncalgary.com/';

    
    if(url.lastIndexOf(local) > 1)
        path = "http://localhost/BWAirportCalgary/";
    else if(url.lastIndexOf(live) > 1)
         path = "http://www.bestwesternairportinncalgary.com/";
    
    return path; 
    
  
}


  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." );
		}
	 }
    }
