﻿


    function RemovePostPage() { 
        if(getObj("selectHotelForm")!=null)
        {  
            getObj("selectHotelForm").removeAttribute("action");
            getObj("selectHotelForm").removeAttribute("target");  
            getObj("__VIEWSTATE").value="";
            getObj("selectHotelForm").id='aspnetForm';
            getObj("__VIEWSTATE").value= getObj("sViewState").value;
        }
    }


function setOutline()
{
if(getObj("div_hoteldropdownarea")!=null) 
 getObj("div_hoteldropdownarea").style.border="2px solid red"; 
 if(getObj("div_hotel_dropdown")!=null)
   getObj("div_hotel_dropdown").style.border="1px solid red";
}


function setbutton()
{
    if(getObj("srp").value=="SelectLocation")
    {
    getObj("imgBook").style.display='block';
    getObj("inputBook").style.display='none';
    }
    else
    {
    getObj("imgBook").style.display='none';
    getObj("inputBook").style.display='block';
  
    
    if(getObj("div_hoteldropdownarea")!=null) 
        getObj("div_hoteldropdownarea").style.border="2px solid #4a4a4a"; 
    if(getObj("div_hotel_dropdown")!=null)
        getObj("div_hotel_dropdown").style.border="0px solid red";
    
    }
}

    function BookHotel()
	{		
	
	     if(getObj("aspnetForm")!=null)
           getObj("aspnetForm").id='selectHotelForm';
           
	        var hotelValue = getObj("srp").value;

            if(hotelValue=="AustrianChalet")
            {             
             getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62087&suppressSSLPopup=true&disablenav=true&sob=P2745";		 

            }
            if(hotelValue=="BarclayHotel")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62102&suppressSSLPopup=true&disablenav=true&sob=P2746";		 
            }
            if(hotelValue=="CarltonPlaza")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62063&suppressSSLPopup=true&disablenav=true&sob=P2747";		 
            }
            if(hotelValue=="ChemainusInn")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62113&suppressSSLPopup=true&disablenav=true&sob=P2748";		 
            }
            if(hotelValue=="CowichanValley")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62068&suppressSSLPopup=true&disablenav=true&sob=P2749";		 
            }
            if(hotelValue=="DorchesterHotel")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62076&suppressSSLPopup=true&disablenav=true&sob=P2750";		 
            }
            if(hotelValue=="EmeraldIsle")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62059&suppressSSLPopup=true&disablenav=true&sob=P2751";		 
            }
            if(hotelValue=="InnerHarbour")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62075&suppressSSLPopup=true&disablenav=true&sob=P2752";		 
            }
            if(hotelValue=="NorthgateInn")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62104&suppressSSLPopup=true&disablenav=true&sob=P2753";		 
            }
            if(hotelValue=="TinWis")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62079&suppressSSLPopup=true&disablenav=true&sob=P2754";		 
            }
            if(hotelValue=="WesterlyHotel")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62116&suppressSSLPopup=true&disablenav=true&sob=P2755";		 
            }
			SendMail(hotelValue);
	}


function BookHotelRoom(hotelId) 
			{        

	      if(getObj("aspnetForm")!=null)
           getObj("aspnetForm").id='selectHotelForm';
             hotelValue= hotelId;

            if(hotelValue=="AustrianChalet")
            { 
             getObj("selectHotelForm").target="_blank";	
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62087&suppressSSLPopup=true&disablenav=true&sob=P2745";		 
            }
            if(hotelValue=="BarclayHotel")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62102&suppressSSLPopup=true&disablenav=true&sob=P2746";		 
            }
            if(hotelValue=="CarltonPlaza")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62063&suppressSSLPopup=true&disablenav=true&sob=P2747";		 
            }
            if(hotelValue=="ChemainusInn")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62113&suppressSSLPopup=true&disablenav=true&sob=P2748";		 
            }
            if(hotelValue=="CowichanValley")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62068&suppressSSLPopup=true&disablenav=true&sob=P2749";	
             	 
            }
            if(hotelValue=="DorchesterHotel")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62076&suppressSSLPopup=true&disablenav=true&sob=P2750";		 
            }
            if(hotelValue=="EmeraldIsle")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62059&suppressSSLPopup=true&disablenav=true&sob=P2751";		 
            }
            if(hotelValue=="InnerHarbour")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62075&suppressSSLPopup=true&disablenav=true&sob=P2752";		 
            }
            if(hotelValue=="NorthgateInn")
            {           
            getObj("selectHotelForm").target="_blank";           
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62104&suppressSSLPopup=true&disablenav=true&sob=P2753";		 
            }
            if(hotelValue=="TinWis")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62079&suppressSSLPopup=true&disablenav=true&sob=P2754";		 
            }
            if(hotelValue=="WesterlyHotel")
            { getObj("selectHotelForm").target="_blank";
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62116&suppressSSLPopup=true&disablenav=true&sob=P2755";		 
            }
			SendMail(hotelValue);
			
		
			
	}

    function BookHotelBlogPage(hotelId)
    {
   
        hotelValue= hotelId;
        if(hotelValue=="NorthgateInn")
        { 
              getObj("selectHotelForm").target="_blank";           
             getObj("selectHotelForm").action="http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62104&suppressSSLPopup=true&disablenav=true&sob=P2753";		  
           window.open("http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62104&suppressSSLPopup=true&disablenav=true&sob=P2753");
        }
        if(hotelValue=="TinWis")
        {
             window.open("http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62079&suppressSSLPopup=true&disablenav=true&sob=P2754");
        }
        if(hotelValue=="ChemainusInn")
        {
             window.open("http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62113&suppressSSLPopup=true&disablenav=true&sob=P2748");
        }
         if(hotelValue=="WesterlyHotel")
        {
             window.open("http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62116&suppressSSLPopup=true&disablenav=true&sob=P2755");
        }
         if(hotelValue=="CarltonPlaza")
        {
             window.open("http://book.bestwestern.com/bestwestern/priceAvail.do?resumeSearch=true&propertyCode=62063&suppressSSLPopup=true&disablenav=true&sob=P2747");
        }
        SendMail(hotelValue);
    }









	function Validate1()
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		
		if(getObj("Name").value=='')
		{
			alert("Please enter your name");
			getObj("RequiredFieldValidator1").style.visibility="hidden";
			getObj("RequiredFieldValidator3").style.visibility="visible";
			 getObj("Name").focus();
			return false;
		}
		
		if(getObj("FromEmail").value=='')
		{
			alert("Please enter your valid email address");
			getObj("RequiredFieldValidator3").style.visibility="hidden";
			getObj("RequiredFieldValidator1").style.visibility="visible";
			 getObj("FromEmail").focus();
			return false;
		}
		if (!filter.test(getObj("FromEmail").value))
		{
			alert("Please enter your valid email address");
			getObj("RequiredFieldValidator1").style.visibility="hidden";
			getObj("RegularExpressionValidator1").style.visibility="visible";
				 getObj("FromEmail").focus();
			return false;
		}

        if(getObj("ToEmail").value=='')
		{
			alert("Please enter a valid email address of the recipient");
			getObj("RequiredFieldValidator2").style.visibility="visible";
			 getObj("ToEmail").focus();
			return false;
		}
		
		if (!filter.test(getObj("ToEmail").value))
		{
			alert("Please enter a valid email address of the recipient");
			getObj("RegularExpressionValidator2").style.visibility="visible";
			 getObj("ToEmail").focus();
			return false;
		}
		
		if(getObj("Subject").value=='')
		{
			alert("Please enter a subject line for the email");
			getObj("RequiredFieldValidator4").style.visibility="visible";
			 getObj("Subject").focus();
			return false;
		}

     var ok = 0;
	  if(confirm('Your email has been sent!  Would you like to subscribe to our hotel e-newsletter to receive updates on specials happening in and around our hotel?'))
	  {
	        ok = 1
    	  //window.getObj("hidMail").value = 1;
	  }        
	 
	 window.getObj("hidMail").value = ok;
	  
		return true;
	}

	function Validate2()
	{
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

		if(getObj("FromEmail").value=='')
		{
			alert("Please enter your valid email address");
			getObj("RequiredFieldValidator3").style.visibility="hidden";
			getObj("RequiredFieldValidator1").style.visibility="visible";
			getObj("FromEmail").focus();
			return false; 
		}
		if (!filter.test(getObj("FromEmail").value))
		{
			alert("Please enter your valid email address");
			getObj("RequiredFieldValidator1").style.visibility="hidden";
			getObj("RequiredFieldValidator3").style.visibility="hidden";
			getObj("RegularExpressionValidator1").style.visibility="visible";
			getObj("FromEmail").focus();
			return false;
		}

        window.getObj("hidMail").value = 1;
	    return true;
	}
	
	
    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()
    {
        var url = self.location.href;
        url = url.toLowerCase();
        var path = '';   

        var local = 'localhost/';
        var server = 'server/';
        var live  = 'bestwesternvancouverisland.com/';

        if(url.lastIndexOf(local) > 1)
        path = "http://localhost/BWVancouverIsland/"; 
        else if(url.lastIndexOf(live) > 1)
        path = "http://www.bestwesternvancouverisland.com/"; 

        return path;   
    }
    
    function SendMail(hotelValue)
    {  
    	


              
        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("hotelValue="+hotelValue);    
           }   
     }


    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." );
		}
	 }
    }
   
   
       //////////////////////////////////////////Js Code for Tab 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();
        }
    
   /////////////////////////////////////////////////////////////////////////////////////
   
     var showcount = 0;   
   
	function SetOpacity(object,opacityPct)
	{
		// IE.
		object.style.filter = 'alpha(opacity=' + opacityPct + ')';
		// Old mozilla and firefox
		object.style.MozOpacity = opacityPct/100;
		// Everything else.
		object.style.opacity = opacityPct/100;
	}
	function ChangeOpacity(id,msDuration,msStart,fromO,toO)
	{
	  var element=document.getElementById(id);
	  var opacity = element.style.opacity * 100;
	  var msNow = (new Date()).getTime();
	  opacity = fromO + (toO - fromO) * (msNow - msStart) / msDuration;
	  
	  	 
	  if (opacity<0) 
	    SetOpacity(element,0)
	  else if(opacity==undefined)
	   SetOpacity(element,0)
	  else if (opacity>100)
	    SetOpacity(element,100)
	  else
	  {	 
	    SetOpacity(element,opacity);
	    element.timer = window.setTimeout("ChangeOpacity('" + id + "'," + msDuration + "," + msStart + "," + fromO + "," + toO + ")",1);
	  }
	  
	}
	function FadeIn(id)
	{
	  var element=document.getElementById(id);
	  if (element.timer) window.clearTimeout(element.timer); 
	  var startMS = (new Date()).getTime();
     
	  element.timer = window.setTimeout("ChangeOpacity('" + id + "',1000," + startMS + ",0,100)",1);
	}
	function FadeOut(id)
	{
	  var element=document.getElementById(id);
	  if (element.timer) window.clearTimeout(element.timer); 
	  var startMS = (new Date()).getTime();
	  element.timer = window.setTimeout("ChangeOpacity('" + id + "',500," + startMS + ",100,0)",1);
	}
   


