<!--

//Creating a date object from the arrival date forms

function switchMonth(stringMonth14) {

	var i = stringMonth14;

	switch (i) {

		case 0:
			return("Jan");
			break;

		case 1:
			return("Feb");
			break;

		case 2:
			return("Mar");
			break;

		case 3:
			return("Apr");
			break;

		case 4:
			return("May");
			break;

		case 5:
			return("Jun");
			break;

		case 6:
			return("Jul");
			break;

		case 7:
			return("Aug");
			break;

		case 8:
			return("Sep");
			break;

		case 9:
			return("Oct");
			break;

		case 10:
			return("Nov");
			break;

		case 11:
			return("Dec");
			break;
	}
}

function adate() {
	var gotday = document.search.day.options[document.search.day.selectedIndex].text;
	var gotmonth = document.search.month.options[document.search.month.selectedIndex].text;
	var gotyear = document.search.year.options[document.search.year.selectedIndex].text;
	var gotdate = gotmonth + " " + gotday + ", " + gotyear ;
	var datestring = gotdate.toString();
	searchdate = new Date(datestring);
	searchstring = searchdate.toString();
	todow = searchstring.substring(0,3); 		
	tomo = searchstring.substring(4,10);      

//object converted to milliseconds
   arrtime = searchdate.getTime();

//Creating new date Object in milliseconds
	now = new Date();
	currtime = now.getTime(); 

//convert 3 nights into milliseconds and 21 nights into milliseconds
//add 1 day to make default 1 day beyond restriction 1/13/09 - clk
	delaytime = 4 * 24 * 60 * 60 * 1000; 

//add 3 nights in milliseconds to arrival time
	add14night = delaytime + currtime;

//convert todays date + 3 nights back to a date string
	newDate14 = new Date(add14night)
	stringDate14 = newDate14.getDate()

//converts month to month + 3 nights
	stringMonth14 = newDate14.getMonth();

	x = switchMonth(stringMonth14)

//convert todays date + 14 nights back to a date string
	document.search.day.selectedIndex = (stringDate14 - 1);  //Set index correctly
	document.search.day.options[document.search.day.selectedIndex].text = stringDate14;
	document.search.month.selectedIndex = (stringMonth14);
	document.search.month.options[document.search.month.selectedIndex].text = x;

}

function adate2() {
	var gotdiscountCode = document.search.discountCode.value;
	var gotnights = document.search.nights.options[document.search.nights.selectedIndex].text;
	var gotday = document.search.day.options[document.search.day.selectedIndex].text;
	var gotmonth = document.search.month.options[document.search.month.selectedIndex].text;
	var gotyear = document.search.year.options[document.search.year.selectedIndex].text;
	var gotdate = gotmonth + " " + gotday + ", " + gotyear ;
	var datestring = gotdate.toString();
	searchdate = new Date( datestring  );
	searchstring = searchdate.toString();
	todow = searchstring.substring(0,3); 		
	tomo = searchstring.substring(4,10);     
	document.search.rategroup.value = "";
	document.search.unittype12.value = "";
	document.search.unittype13.value = "";
	document.search.dayWeek.value = todow;

//object converted to milliseconds
	arrtime = searchdate.getTime();

//Creating new date Object in milliseconds
	now = new Date();
	currtime = now.getTime();

//subtract arrivaltime - current time, in milliseconds
	difference = arrtime - currtime;

//convert 3 days into milliseconds
	delaytime = 3 * 24 * 60 * 60 * 1000;
	future = 335 * 24 * 60 * 60 * 1000;

	if (difference <= delaytime) {
		alert("No OnLine booking within 3 days of today's date");
		return false;
	}

	if (difference >= future) {
		alert("We only take online bookings 11 months in advance.");
		return false;
	}

	if (gotdiscountCode == "N") {
		if(parseInt(gotnights) < 3) {
			alert("This discount requires a 3 night minimum booking.");
			return false;
		}

		if ((gotmonth == "Nov") || (gotmonth == "Dec") || (gotmonth == "Jan") || (gotmonth == "Feb") || (gotmonth == "Mar") || (gotmonth == "Apr")) {
			document.search.rategroup.value = "3F";
			document.search.unittype12.value = "3";
			//return true;
		}

		else {
			alert("Discount good November 1 - April 30 with a 3 night minimum.");
			return false;
		}
	}

	if (gotdiscountCode == "A") {
		if (parseInt(gotnights) < 3) {
			alert("This discount requires a 3 night minimum booking.");
			return false;
		}

		document.search.rategroup.value = "3F";
		document.search.unittype13.value = "3";

	}

//if a unit is entered, don't pass a rategroup. this is because the string values for unittype 12 and 13 to allow and disallow discounts on units..'3' and 'N' will always get overwritten by entering a unit

	var Unit = document.search.selectunit.value

	var UnitLength = Unit.length

	if (UnitLength > 1) {
		document.search.rategroup.value = "";
	}

	return (setLimit());
}


//-->