//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function MakeReservationsVOne(szName, szImageUrl, szUnitCode, SzPackage){
		var e = document.makeReservations;
		var iArrivalMonth = e.arrivalMonth.options[e.arrivalMonth.selectedIndex].value;
		var iArrivalDay = e.arrivalDay.options[e.arrivalDay.selectedIndex].value;
		var iArrivalYear = e.arrivalYear.options[e.arrivalYear.selectedIndex].value;
		var iNights = e.nights.options[e.nights.selectedIndex].value;
		var iAdults = e.adults.options[e.adults.selectedIndex].value;
		var iChildren = e.children.options[e.children.selectedIndex].value;
		var d = new Date();
		//alert("We are sorry, but our online booking system is unavailable. For reservation assistance, please call 1-888-SEASIDE.")
		if (iArrivalYear == d.getFullYear() && iArrivalMonth == (d.getMonth() + 1) && iArrivalDay <= d.getDate()){
			alert("You have selected an invalid date. Please select a new arrival date.")
		}
		else if (iArrivalYear == d.getFullYear() && iArrivalMonth < (d.getMonth() + 1)){
			alert("The date you selected is already past. Please select a new arrival date.")
		}
		else {
			
			//alert("Online bookings is not available at this time. Please call Cottage Rental Agency at 888.277.8696.")
			
			/*
			alert("http://v1cra.mindvisions.com/V1WebControlsRay/ResvMain.aspx?" +
			"arvDate=" + iArrivalMonth + "/" + iArrivalDay + "/" + iArrivalYear +
			"&iNgts=" + iNights + "&iAdults=" + iAdults +
			"&iChildren=" + iChildren +
			"&Package=" + SzPackage + 
			"&RmCode=" + szUnitCode + 
			"&propertyName=" + szName +
			"&imageUrl=" + szImageUrl);
			*/
			//V1 LINK: http://v1cra.mindvisions.com/V1WebControlsRay/ResvMain.aspx?arvDate=10/10/2008&iNgts=1&iAdults=1&Package=ABOVE&RmCode=ABOVE
			
			//v1CRA.mindvisions.com server
			//window.open("http://v1cra.mindvisions.com/V1WebControlsRay/ResvMain.aspx?" +	

			
			//INTRAWEST SERVER
			//window.open("http://onlinebooking.cottagerentalagency.com/V1CRABook/ResvMain.aspx?" +			
			
			window.open("https://onlinebooking.cottagerentalagency.com/V1CRABook/ResvMain.aspx?" +			
			"arvDate=" + iArrivalMonth + "/" + iArrivalDay + "/" + iArrivalYear +
			"&iNgts=" + iNights + "&iAdults=" + iAdults +
			"&iChildren=" + iChildren +
			"&Package=" + SzPackage + 
			"&RmCode=" + szUnitCode + 
			"&propertyName=" + szName +
			"&imageUrl=" + szImageUrl, "MakeReservations", " width=820,height=650,menubar=0,scrollbars=1,toolbar=1,status=1");
			
			//window.open("http://v1cra.mindvisions.com/V1WebControlsRay/ResvMain.aspx?arvDate=06/26/2008&iNgts=1&iAdults=1&Package=MC4&RmCode=MC4", " width=730,height=650,menubar=0,scrollbars=1,toolbar=1,status=1");

		}
	}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
  var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;  
  if (popWidth > 0) features += (features.length > 0 ? ',' : '') + 'width=' + popWidth;
  if (popHeight > 0) features += (features.length > 0 ? ',' : '') + 'height=' + popHeight;
  if (winAlign && winAlign != "" && popWidth > 0 && popHeight > 0) {
    if (document.all || document.layers || document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
		if (winAlign.indexOf("center") != -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
		if (winAlign.indexOf("bottom") != -1) topPos = h-popHeight; if (winAlign.indexOf("right") != -1) leftPos = w-popWidth; 
		if (winAlign.indexOf("left") != -1) leftPos = 0; if (winAlign.indexOf("top") != -1) topPos = 0; 						
    features += (features.length > 0 ? ',' : '') + 'top=' + topPos+',left='+leftPos;}
  if (document.all && borderless && borderless != "" && features.indexOf("fullscreen") != -1) features+=",fullscreen=1";
  if (window["popupWindow"] == null) window["popupWindow"] = new Array();
  var wp = popupWindow.length;
  popupWindow[wp] = window.open(theURL,winName,features);
  if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;  
  if (document.all || document.layers || document.getElementById) {
    if (borderless && borderless != "") {popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
    if (alwaysOnTop && alwaysOnTop != "") {
    	ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
    	popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
    if (autoCloseTime && autoCloseTime > 0) {
    	popupWindow[wp].document.body.onbeforeunload = function() {
  			if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
    		window.onbeforeunload = null;	}  
   		autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
  	window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }   
  document.MM_returnValue = (ignorelink && ignorelink != "") ? false : true;
}

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function isDate(dateStr) {

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
return false;
}

month = matchArray[1]; // p@rse date into variables
day = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn`t have 31 days!")
return false;
}

if (month == 2) { // check for february 29th
	var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	if (day > 29 || (day==29 && !isleap)) {
		alert("February " + year + " doesn`t have " + day + " days!");
		return false;
	}
}
return true; // date is valid
}

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function ValidateContactForm(){
		var e = document.contact;
		if (e.First.value == ""){
			alert("Please enter your first name.");
			e.First.focus(); e.First.select(); return false
		}
		if (e.Last.value == ""){
			alert("Please enter your last name.");
			e.Last.focus(); e.Last.select(); return false
		}
		if (e.Email.value == "" || e.Email.value.length < 7 || e.Email.value.indexOf("@") == -1){
			alert("Please enter your email address.");
			e.Email.focus(); e.Email.select(); return false
		}
		if (e.Comment.value == ""){
			alert("Please enter your question or comment.");
			e.Comment.focus(); e.Comment.select(); return false
		}
	}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function MakeReservations(iRentalId, szName, szImageUrl, szUnitCode){
		var e = document.makeReservations;
		var iArrivalMonth = e.arrivalMonth.options[e.arrivalMonth.selectedIndex].value;
		var iArrivalDay = e.arrivalDay.options[e.arrivalDay.selectedIndex].value;
		var iArrivalYear = e.arrivalYear.options[e.arrivalYear.selectedIndex].value;
		var iNights = e.nights.options[e.nights.selectedIndex].value;
		var iAdults = e.adults.options[e.adults.selectedIndex].value;
		var iChildren = e.children.options[e.children.selectedIndex].value;
		var d = new Date();
		//alert("We are sorry, but our online booking system is unavailable. For reservation assistance, please call 1-888-SEASIDE.")
		//if (confirm("You have chosen to book -" + szName + "- on " + iArrivalMonth + "/" + iArrivalDay + "/" + iArrivalYear + " for " + iNights + " night(s). " +
		//"To continue with this reservation, please click the -OK- button below.")){
		if (iArrivalYear == d.getFullYear() && iArrivalMonth == (d.getMonth() + 1) && iArrivalDay < d.getDate()){
			alert("The date you selected is already past. Please select a new arrival date.")
		}
		else if (iArrivalYear == d.getFullYear() && iArrivalMonth < (d.getMonth() + 1)){
			alert("The date you selected is already past. Please select a new arrival date.")
		}
		else {
			window.open("http://crabeta.mindvisions.com/cottages_temp.asp?" +
			//", "MakeReservations", " width=760,height=450,menubar=0,scrollbars=1,toolbar=1,status=1");
			//window.open("Booking/hurricane.asp?" +
			//window.open("https://onlinebooking.cottagerentalagency.com/aspCRA/Book/scripts/asp/book.asp?" +
//			//window.open("Booking/servernotavailable.asp?" +
			"action=availability&propertyId=" + iRentalId + "&propertyName=" + szName +
			"&imageUrl=" + szImageUrl + "&unitCode=" + szUnitCode + 
			"&arrivalMonth=" + iArrivalMonth + "&arrivalYear=" + iArrivalYear +
			"&arrivalDay=" + iArrivalDay + "&nights=" + iNights + "&adults=" + iAdults +
//			"&children=" + iChildren, "MakeReservations", "width=700,height=400,menubar=0,scrollbars=1,toolbar=1,status=1")
			"&children=" + iChildren, "MakeReservations", " width=730,height=650,menubar=0,scrollbars=1,toolbar=1,status=1")
		}
		//}
	}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function MakeSpecialReservations(iRentalId, szName, szImageUrl, szUnitCode, promotionid){
		var e = document.makeReservations;
		var iArrivalMonth = e.arrivalMonth.options(e.arrivalMonth.selectedIndex).value;
		var iArrivalDay = e.arrivalDay.options(e.arrivalDay.selectedIndex).value;
		var iArrivalYear = e.arrivalYear.options(e.arrivalYear.selectedIndex).value;
		var iNights = e.nights.options(e.nights.selectedIndex).value;
		var iAdults = e.adults.options(e.adults.selectedIndex).value;
		var iChildren = e.children.options(e.children.selectedIndex).value;
		var rategroup = e.rategroup.value;
		var d = new Date();
		//alert("We are sorry, but our online booking system is unavailable. For reservation assistance, please call 1-888-SEASIDE.")
		//if (confirm("You have chosen to book -" + szName + "- on " + iArrivalMonth + "/" + iArrivalDay + "/" + iArrivalYear + " for " + iNights + " night(s). " +
		//"To continue with this reservation, please click the -OK- button below.")){
		if (iArrivalYear == d.getFullYear() && iArrivalMonth == (d.getMonth() + 1) && iArrivalDay < d.getDate()){
			alert("The date you selected is already past. Please select a new arrival date.")
		}
		else if (iArrivalYear == d.getFullYear() && iArrivalMonth < (d.getMonth() + 1)){
			alert("The date you selected is already past. Please select a new arrival date.")
		}
		else {
			//window.open("Booking/hurricane.asp?" +
			window.open("https://onlinebooking.cottagerentalagency.com/aspCRA/Book/scripts/asp/book.asp?" +
			//window.open("Booking/servernotavailable.asp?" +
			"action=availability&propertyId=" + iRentalId + "&propertyName=" + szName +
			"&imageUrl=" + szImageUrl + "&unitCode=" + szUnitCode + 
			"&arrivalMonth=" + iArrivalMonth + "&arrivalYear=" + iArrivalYear +
			"&arrivalDay=" + iArrivalDay + "&nights=" + iNights + "&adults=" + iAdults +
			"&children=" + iChildren + "&rategroup=" + rategroup + "&IsSpecial=Yes"+'&promotionid=' + promotionid , "MakeReservations", "width=700,height=400,menubar=0,scrollbars=1,toolbar=1,status=1")
		}
		//}
	}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	function ChangeRentalPhoto(iRentalId){
		var e = document.photos;
		var newImage = new Image();
		var iPhotoId = e.photoId.options[e.photoId.selectedIndex].value;
		newImage.src = "http://www.cottagerentalagency.com/images/cottages/" + iRentalId + "_" + iPhotoId + ".jpg";
		document.getElementById("RentalPhoto").src = newImage.src
	}