<!--
/*
checkSubmitAvailability.js
this is from hidden form with arrive and depart dates
if ok goes to available rooms.php
*/

function preSubmit()
{

	errors = ""; // to display errors
	anyErrors = "no";
	
	//check arrive date
	if (document.getElementById("arriveDateElement").value.length < 1)
	{
		errors += " Please enter an arrival date ";
		anyErrors = "yes";
	}

	//check depart date
	if (document.getElementById("departDateElement").value.length < 1)
	{
		errors += " Please enter a departure date ";
		anyErrors = "yes";
	}
	//check not before today
todaysDate(); // in dateFunctions.js
// returns Passdata;
testA = passData;
//alert("TA " + testA);
if (testA > chosenArriveDate)
{
		errors += " Your arrival date is before today's date! Please re-enter ";
		anyErrors = "yes";
}

	//check departure < arrival
	if(chosenArriveDate > chosenDepartDate)
	{
		errors += " Your arrival date is after your departure date ! Please re-enter ";
		anyErrors = "yes";
	}
// submit	
	if (anyErrors == "yes")
	{
		alert(errors);
	}
	else
	{
	top.location.href = "http://redcetera.com/redHotel/availableRooms/availableRooms.html";
	//document.dateToAvailableForm.submit();
	}
}
// -->

