﻿

function BookHotel(){

  
        var fmonth = getObj("arrivalMonthYear").value.substring(4,6);
        var tmonth = getObj("departureMonthYear").value.substring(4,6);
        
        fmonth=parseFloat(fmonth)+1;
        tmonth=parseFloat(tmonth)+1;
        
       
        
        var arrYear=getObj("arrivalMonthYear").value.substring(0,4);
        var arrMonth = getObj("arrivalMonthYear").value.substring(4,6);
        arrMonth=parseFloat(arrMonth)+1;
        var arrDay=getObj("arrivalDay").value;
        
        var arrDate=arrYear+"-"+arrMonth+"-"+arrDay;
        
        
        var depYear=getObj("departureMonthYear").value.substring(0,4);
        var depMonth = getObj("departureMonthYear").value.substring(4,6);
        depMonth=parseFloat(depMonth)+1;
        var depDay=getObj("departureDay").value;
        
        var depDate=depYear+"-"+depMonth+"-"+depDay;
        
//     
//        iRet = window.open("http://www.choicehotels.ca/hotels/roomRates?hotel=CN181" +
//        "&srp=" + getObj("srp").value + 
//        "&minisrp=" + getObj("minisrp").value + 
//        "&day=" + getObj("arrivalDay").value + 
//        "&month=" + fmonth + 
//        "&depart_day=" + getObj("departureDay").value + 
//        "&depart_month=" + tmonth + 
//        "&nadult=" + getObj("nadult").value + 
//        "&nchild=" + getObj("nchild").value + 
//        "&destination=Vancouver" );
        
        
        
//        iRet = window.open("http://reservation.worldweb.com/Bookings-nr104/record-edit.html?command=roomsearch&access_code=&adminmode=0"+
//        "&area_id=&customer_id="+
//        "&date_from="+ arrDate +
//        "&date_to="+ depDate +
//        "&exchange_rates=CAD&external_customer_id=&folio_id=&hotel_id=372&hotel_id=372&language=english"+
//        "&listing_id=372&mode=command&num_adults=1&num_children=0&num_nights=1&reservationcode_id="+
//        "&sourcecode_id=&table=hotels&transaction_id=-1" );

        //Changed on feb 3 2010
        iRet = window.open("http://reservation.worldweb.com/Bookings-nr104/record-edit.html?command=roomsearch&access_code=&adminmode=0"+
        "&area_id=&customer_id="+
        "&date_from="+ arrDate +
        "&date_to="+ depDate +
        "&exchange_rates=CAD&external_customer_id=&folio_id=&hotel_id=881&hotel_id=881&language=english"+
        "&listing_id=881&mode=command&num_adults=1&num_children=0&num_nights=1&reservationcode_id="+
        "&sourcecode_id=&table=hotels&transaction_id=-1" );

         
  
}



	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";
			return false;
		}
		
		if(getObj("FromEmail").value=='')
		{
			alert("Please enter your valid email address");
			getObj("RequiredFieldValidator3").style.visibility="hidden";
			getObj("RequiredFieldValidator1").style.visibility="visible";
			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";
			return false;
		}

        if(getObj("ToEmail").value=='')
		{
			alert("Please enter a valid email address of the recipient");
			getObj("RequiredFieldValidator2").style.visibility="visible";
			return false;
		}
		
		if (!filter.test(getObj("ToEmail").value))
		{
			alert("Please enter a valid email address of the recipient");
			getObj("RegularExpressionValidator2").style.visibility="visible";
			return false;
		}
		
		if(getObj("Subject").value=='')
		{
			alert("Please enter a subject line for the email");
			getObj("RequiredFieldValidator4").style.visibility="visible";
			return false;
		}

    
	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?'))
	  {
	    var ok = 1
    	  //window.getObj("hidMail").value = 1;
    	  
	  }        
	 var cancel =0
	 if(ok ==1 && cancel == 0)
	  {
	   window.getObj("hidMail").value = 1;
	  }  
	   else 
	  {
	    window.getObj("hidMail").value = 0;
	  }
	  
		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";
			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";
			return false;
		}

        window.getObj("hidMail").value = 1;
	    return true;
	}