// JavaScript Document
function openWin(arg) {

 myWin = open (arg,"newWindow2","width=640,height=480,status=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes");
}




	function ValidateForm()
	{
		//get the number of adults and children 
		var NumAdult
		var NumChild
			
		NumAdult = parseInt(document.frmSearch.numAdults.value)
		NumChild = parseInt(document.frmSearch.numChildren.value)
			
		//get number of rooms required
		var NumRoom
			
		NumRoom = parseInt(document.frmSearch.numRooms.value)
			
		//get todays, the arrival and the departure dates
		var now = new Date()
			
		var Arrive = new Date();
		Arrive = new Date(document.frmSearch.selYearStart.value, (parseInt(document.frmSearch.selMonthStart.value) - 1), document.frmSearch.selDayStart.value, 23, 0, 0, 0)
		var Depart = new Date();
		Depart = new Date(document.frmSearch.selYearEnd.value, (parseInt(document.frmSearch.selMonthEnd.value) - 1), document.frmSearch.selDayEnd.value)

			
		//at least 1 adult has to be booked in with the party
		if (document.frmSearch.numAdults.value < 1)
		{
			alert("At least one adult must be in the party")
			return false;	
		}
			
		//at least 1 room has to be selected
		if (document.frmSearch.numRooms.value < 1)
		{
			alert("At least one room must be reserved")
			return false;	
		}
			
		if(Arrive < now)
		{
			alert("The arrival date cannot be in the past.")
			return false;
		}
			
		if(Depart < Arrive)
		{
			alert("The departure date cannot be before the arrival date.")
			return false;
		}
			
		//the arrival and departure date must not be the same
		if ((Arrive.getYear() == Depart.getYear()) && (Arrive.getMonth() == Depart.getMonth()) && (Arrive.getDate() == Depart.getDate()))
		{
			alert("The Arrival and Departure dates cannot be the same.")
			return false;
		}

		//if february is selected, then the day selected cannot be higher than the 28th except for leap years
		if (((document.frmSearch.selMonthStart.value == 2 && (document.frmSearch.selYearStart.value % 4) == 0 && document.frmSearch.selDayStart.value > 29) || (document.frmSearch.selMonthStart.value == 2 && (document.frmSearch.selYearStart.value % 4) != 0 && document.frmSearch.selDayStart.value > 28)) || ((document.frmSearch.selMonthEnd.value == 2 && (document.frmSearch.selYearEnd.value % 4) == 0 && document.frmSearch.selDayEnd.value > 29) || (document.frmSearch.selMonthEnd.value == 2 && (document.frmSearch.selYearEnd.value % 4) != 0 && document.frmSearch.selDayEnd.value > 28)))
		{
			alert("Please check your Arrival and Departure dates. They are invalid!")
			return false;
		}
			
		//if a month with only 30 days in it is selected, then the day selected cannot be higher than the 30th
		if (((document.frmSearch.selMonthStart.value == 4 || document.frmSearch.selMonthStart.value == 6 || document.frmSearch.selMonthStart.value == 9 || document.frmSearch.selMonthStart.value == 11) && document.frmSearch.selDayStart.value > 30) || ((document.frmSearch.selMonthEnd.value == 4 || document.frmSearch.selMonthEnd.value == 6 || document.frmSearch.selMonthEnd.value == 9 || document.frmSearch.selMonthEnd.value == 11) && document.frmSearch.selDayEnd.value > 30))
		{
			alert("Please check your Arrival and Departure dates. They are invalid!")
			return false;
		}
		
		
		if (document.frmSearch.roomType.value == 0)
		{
			if (document.frmSearch.numRooms.value == 1)
			{
				document.frmSearch.action = "All.asp"
			}
			else if (document.frmSearch.numRooms.value > 1)
			{
				document.frmSearch.action = "Multi.asp"
			}
		}
				
	}
	//function setAction(sAction)
{
	// Change form's target page
	//document.frmSearch.action=sAction;
}

function GetSearchPage()
{
	document.frmSearch.SelPreviousSearch.value = document.frmSearch.selAccomSearch.selectedIndex;
	// to redirect to the correct search page
	document.frmSearch.UsingPreviousSearch.value = 1

	setAction(SearchPageArray[document.frmSearch.selAccomSearch.selectedIndex]);
	SubmitPage();
}

function SubmitPage()
{
	// Set the the combo box to the first entry. So in this way the onChange Event Event
	// will be fired next time that the user want to use it.
	// We also submit the page to the correct form...
	document.forms['frmSearch'].submit();

	document.forms['frmSearch'].selAccomSearch.value=0;

	document.frmSearch.UsingPreviousSearch.value=0;
}

function updlocation( blnUseList ) {
	if(blnUseList) {
		// update location name based on dropdown list
		document.forms['frmSearch'].txtLocation.value = document.forms['frmSearch'].selLocation.options[document.forms['frmSearch'].selLocation.selectedIndex].text;
		document.forms['frmSearch'].hdnLocation.value = document.forms['frmSearch'].selLocation.options[document.forms['frmSearch'].selLocation.selectedIndex].value;
	}
	else	// blank out the selected code
		document.forms['frmSearch'].hdnLocation.value = '';
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

