// function checks a date value to make sure its valid
function validDate(aDate) {
	var dateexp = /^(\d{1,2}\/\d{1,2}\/\d{4})$/;
    if (!dateexp.test(aDate)) { return false; } 	
	var	temp = new String(aDate), m = 0, d = 0;
	
	for (i=0; i < temp.length; i++){ 
		var str = temp.charAt(i); 
		if (str == "/") { if (m == 0) { m = i; } else { d = i; break; }}			
	}
	
	var month = parseInt(temp.substring(0, m), 10);
	var day = parseInt(temp.substring(m + 1, d), 10); 
	var year = parseInt(temp.substring(d + 1, temp.length), 10);								
					
	switch (month) {
		case 1:	case 3:	case 5:	case 7:	case 8:	case 10: case 12:					
			if ((day < 1) || (day > 31)) {  return false;	} break;
		case 2:		
			if ((year % 400 == 0) || (year % 4 == 0)) {	if ((day < 1) || (day > 29)) {  return false;	} break}
			if ((day < 1) || (day > 28)) {  return false; } break;
		case 4:	case 6:	case 9: case 11:
			if ((day < 1) || (day > 30)) {	 return false; } break;
		default: return false;			
	}		
	return true;		
}

var subMnus="";
									
function showmenu(idx,li){
	var subleftoffset=((document.body.offsetWidth-890)/2+21);
	if(document.body.offsetWidth<895)
		subleftoffset=7;
	var sublefts=new Array(6);
	sublefts[0]=subleftoffset;
	sublefts[1]=sublefts[0]+109;
	sublefts[2]=sublefts[1]+129;
	sublefts[3]=sublefts[2]+145;
	sublefts[4]=sublefts[3]+139;
	sublefts[5]=sublefts[4]+135;
	try{
		hideAllMenu();
		var dv=document.getElementById("sub"+idx);
		dv.style.left=sublefts[li];
		dv.style.top=222;
		dv.style.visibility="visible";
	}
	catch(e){}
}

function hideAllMenu(){
	try{
		var ar=subMnus.split(',');
		for(i=0;i<ar.length;i++){
			var dv=document.getElementById("sub"+ar[i]);
			dv.style.visibility="hidden";
		}
	}
	catch(e){}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function isValidEmail(thisEmail){
	var emailexp = /.*\@.*\..*/;
	if (!emailexp.test(thisEmail)) {
		return false;
	} 
	return true;
}

function validateBookDates(thisForm){
	var arMonth=parseInt(thisForm.arr_month.value);
	var arDay=parseInt(thisForm.arr_day.value);
	var arYear=parseInt(thisForm.arr_year.value);
	var dpMonth=parseInt(thisForm.dep_month.value);
	var dpDay=parseInt(thisForm.dep_day.value);
	var dpYear=parseInt(thisForm.dep_year.value);
	
	if(!validDate(arMonth+"/"+arDay+"/"+arYear)){
		alert("You must provide a valid arrival date!");
		thisForm.arr_month.focus();
		return false;
	}
	if(!validDate(dpMonth+"/"+dpDay+"/"+dpYear)){
		alert("You must provide a valid departure date!");
		thisForm.arr_month.focus();
		return false;
	}
	if(dpMonth<arMonth||(dpMonth==arMonth&&dpDay<arDay)){		
		alert("Your arrival date must be on or after your arrival date!");
		thisForm.dep_month.focus();
		return false;
	}
	
	return true;
}

function validateCustInfo(thisForm){
	if(thisForm.custFName.value==""){		
		alert("Please provide your first name!");
		thisForm.custFName.focus();
		return false;
	}
	if(thisForm.custLName.value==""){		
		alert("Please provide your last name!");
		thisForm.custLName.focus();
		return false;
	}
	if(thisForm.custAddress1.value==""){		
		alert("Please provide your street address!");
		thisForm.custAddress1.focus();
		return false;
	}
	if(thisForm.custAddress1.value==""){		
		alert("Please provide your street address!");
		thisForm.custAddress1.focus();
		return false;
	}
	if(thisForm.custCity.value==""){		
		alert("Please provide your city!");
		thisForm.custCity.focus();
		return false;
	}
	if(thisForm.custProv.options[thisForm.custProv.selectedIndex].value==""
		||thisForm.custProv.options[thisForm.custProv.selectedIndex].value=="0"){		
		alert("Please provide your province/state!");
		thisForm.custProv.focus();
		return false;
	}
	if(thisForm.custProv.options[thisForm.custProv.selectedIndex].value=="__"
		&&thisForm.custOProv.value==""){		
		alert("You have selecte Other province/state. Please provide your province/state name!");
		thisForm.custOProv.focus();
		return false;
	}
	if(thisForm.custPostal.value==""){		
		alert("Please provide your postal/zip code!");
		thisForm.custPostal.focus();
		return false;
	}
	if(thisForm.custCountry.options[thisForm.custCountry.selectedIndex].value==""
		||thisForm.custCountry.options[thisForm.custCountry.selectedIndex].value=="0"){		
		alert("Please provide your country!");
		thisForm.custCountry.focus();
		return false;
	}
	if(thisForm.custPhone.value==""){		
		alert("Please provide your phone number!");
		thisForm.custPhone.focus();
		return false;
	}
	if(thisForm.custEmail.value==""||!isValidEmail(thisForm.custEmail.value)){		
		alert("Please provide a valid email address!");
		thisForm.custEmail.focus();
		return false;
	}
	if(thisForm.payingCust.value==""||isNaN(thisForm.payingCust.value)){		
		alert("Please provide the number of guests over 12 years of age!");
		thisForm.payingCust.focus();
		return false;
	}
	if(thisForm.freeCust.value==""||isNaN(thisForm.freeCust.value)){		
		alert("Please provide the number of guests 12 years of age and under! Enter 0 (zero) if none.");
		thisForm.freeCust.focus();
		return false;
	}
	if(thisForm.custEmail.value==""||!isValidEmail(thisForm.custEmail.value)){		
		alert("Please provide a valid email address!");
		thisForm.custEmail.focus();
		return false;
	}
	if(thisForm.ccNum.value==""||isNaN(thisForm.ccNum.value=="")){		
		alert("Please provide your credit card number!");
		thisForm.ccNum.focus();
		return false;
	}
	if(thisForm.expMon.options[thisForm.expMon.selectedIndex].value==""){		
		alert("Please provide your credit card expiration month!");
		thisForm.expMon.focus();
		return false;
	}
	if(thisForm.expYear.options[thisForm.expYear.selectedIndex].value==""){		
		alert("Please provide your credit card expiration year!");
		thisForm.expYear.focus();
		return false;
	}
	
	return true;
}