/***************************************************************************
This function ensures that date from the Input box is parsed to a Java Date Object.
*****************************************************************************/

function ParseDate(dateString)
{
    //Date is in the format of mm/dd/yyyy pulled from textbox.
   date = new Date(dateString)
   return date;
}
/*******************************************************************************
This function ensures that the users select a start date which is less than end date
*********************************************************************************/

function ValidateDate1(startDateStr, endDateStr)
{
   startDate = ParseDate(startDateStr);
   endDate = ParseDate(endDateStr);

   //alert(startDate.toString()); //here is the error - when it convert to a string it is returning funny values.
   //alert(startDate.getDate());
   if (endDate < startDate) {
     alert("Start Date should be less than End Date");
   }
   //else
   //  alert("Bad");
}

function ValidateDate(startDateStr, endDateStr)
{
   //note the absence of the ParseDate function
   //and it's still about the same amount of typing
   startDate = new Date(startDateStr);
   endDate = new Date(endDateStr);
   todayDate = new Date();
   
   
   if (todayDate.getTime() > startDate.getTime()) {	
    alert("Start Date should not be past date");
	
	 return false;
   }else if (endDate.getTime() < startDate.getTime()) {
     alert("Start Date should be less than End Date");
	 return false;
   }else{
	return true;
   }
}
function ValidateDateBooking(startDateStr)
{
   //note the absence of the ParseDate function
   //and it's still about the same amount of typing
   startDate = new Date(startDateStr);
   todayDate = new Date();
   
   
   if (todayDate.getTime() > startDate.getTime()) {	
    alert("Start Date should not be past date");
	
	 return false;
   }else{
	return true;
   }
}

function getTheDay()

{

	myDays = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
		 
	myDate=new Date(eval('"'+document.searchform.fromdate.value+'"'))
		 
	//var thisDay = myDays[myDate.getDay()]
	var thisDay = myDays[document.searchform.hidDay.value]
	if(document.searchform.hidDay.value== myDate.getDay()){	
		return true;
	}else{
		alert("Please select "+ thisDay+".");
		return false;
	}	
}
