﻿

function BookHotel(page){

        var fYear = getObj("arrivalMonthYear").value.substring(0,4);
        var fmonth = getObj("arrivalMonthYear").value.substring(4,6);
        
        var tYear = getObj("departureMonthYear").value.substring(0,4);
        var tmonth = getObj("departureMonthYear").value.substring(4,6);
        
        if (fmonth.substring(0,1) == "0"){
			
            fmonth = fmonth.substring(1,2);			
         }        
         fmonth = parseFloat(fmonth)+1;
        
        
        if (tmonth.substring(0,1) == "0"){        
           tmonth = tmonth.substring(1,2);   		  
         }
        
          tmonth = parseFloat(tmonth)+1;

//        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.choicehotels.ca/hotels/roomRates?hotel=CN522&srp=" + getObj("srp").value +
//		"&minisrp=" +
//        "&day=" + getObj("arrivalDay").value + 
//        "&month=" + fmonth + 
//        "&depart_day=" + getObj("departureDay").value + 
//        "&depart_month=" + tmonth + 
//        "&nadult=" + getObj("nadult").value + 
//        "&nchild=" + getObj("nchild").value + 
//        "&destination=kelowna" );
        
        
    iRet = window.open( "http://www.choicehotels.ca/rooms/CN522?srp="+getObj("srp").value+"&checkin="+ getObj("arrivalDay").value +"-"+fmonth+"-"+fYear+"&checkout="+ getObj("departureDay").value +"-"+tmonth+"-"+tYear);     
        
        
        
        
        
  var pagename=page+"?Visitor=1"
    window.parent.location.href=pagename;	
  return false;
}



	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;
	}