function SetDates(){
//Set the Months
	var objDD1 = document.getElementById("pickupMonthYear");	
	var objDD2 = document.getElementById("dropoffMonthYear");

	var nowDate = new Date();
	var iMonth = nowDate.getMonth();
	var iYear = nowDate.getFullYear();

	var month_name = new Array ("Jan ","Feb ","Mar ","Apr ","May ","Jun ","Jul ","Aug ","Sep ","Oct ","Nov ","Dec ");
	var sMonth, sMonthYear
	for(i=0;i<12;i++)
	{
	iMonth = parseInt(iMonth + 1);
	if (iMonth > 12)
		{iYear = parseInt(iYear +1); iMonth = 1;}
	sMonth = String(iMonth) + String(iYear)
	if (sMonth.length < 6)
		{sMonth = "0" + sMonth;}
	sMonthYear = month_name[iMonth-1] + " " + String ("0" + (iYear - 2000))

	var newOpt = new Option(sMonthYear, sMonth,false,false);
	objDD1.options[objDD1.options.length] = newOpt;
	var newOpt = new Option(sMonthYear, sMonth,false,false);
	objDD2.options[objDD2.options.length] = newOpt;

}

//Set the days for Cars
//We can't hire out cars at less than 7 days notice.
	var chf = document.inputform
	strDate = new Date(addDays(nowDate,7));
	chf.pDay.selectedIndex = strDate.getDate()-1;
	chf.dDay.selectedIndex = strDate.getDate()-1;
	if (parseInt(strDate.getDate()) < parseInt(nowDate.getDate()))
	{
	chf.pickupMonthYear.selectedIndex = chf.pickupMonthYear.selectedIndex + 1;
	}
	chf.dropoffMonthYear.selectedIndex = chf.pickupMonthYear.selectedIndex;
}

function addDays(myDate,days) {
    return new Date(myDate.getTime() + days*24*60*60*1000);
}

function DateInThePast(dd,mmyy,days){
var x = new Date();
var y = new String(mmyy);
x.setDate(dd); x.setMonth(y.slice(0,2)-1); x.setFullYear(y.slice(2,6));
var nowDate = new Date();
strDate = new Date(addDays(nowDate,days));

if (x < strDate)
	return false;
else
	return true;
}

function ValidateCars(theForm){

if (theForm.pickup.value == "") 
	{alert("Please enter a pick-up city.");
	theForm.pickup.focus();
	return false;}

if (theForm.dropoff.value == "") 
	{alert("Please enter a drop-off city.");
	theForm.dropoff.focus();
	return false;}

//Ensure the pick-up day isn't in the past
if (!DateInThePast(theForm.pDay.selectedIndex +1,theForm.pickupMonthYear.value,0))
	{alert("Pick-up date cannot be in the past.");
	theForm.pickupMonthYear.focus();
	return false;}

//We can't hire out cars at less than 7 days notice.
if (!DateInThePast(theForm.pDay.selectedIndex +1,theForm.pickupMonthYear.value,7))
	{alert("We must have at least 7 days notice before pick-up date.");
	theForm.pickupMonthYear.focus();
	return false;}

//Ensure the drop-off day is after the pick-up day.
	var pickupdate = new Date(theForm.pickupMonthYear.options[theForm.pickupMonthYear.selectedIndex].value.substr(2,4),theForm.pickupMonthYear.options[theForm.pickupMonthYear.selectedIndex].value.substr(0,2)-1,theForm.pDay.options[theForm.pDay.selectedIndex].value);
	var dropoffdate = new Date(theForm.dropoffMonthYear.options[theForm.dropoffMonthYear.selectedIndex].value.substr(2,4),theForm.dropoffMonthYear.options[theForm.dropoffMonthYear.selectedIndex].value.substr(0,2)-1,theForm.dDay.options[theForm.dDay.selectedIndex].value);
if (pickupdate >= dropoffdate)
	{alert("Drop-off day must be later than the Pick-up date.");
	theForm.pickupMonthYear.focus();
	return false;}

//Ensure the drop-off day is after the pick-up day.
	var pickupdate = new Date(theForm.pickupMonthYear.options[theForm.pickupMonthYear.selectedIndex].value.substr(2,4),theForm.pickupMonthYear.options[theForm.pickupMonthYear.selectedIndex].value.substr(0,2)-1,theForm.pDay.options[theForm.pDay.selectedIndex].value);
	var dropoffdate = new Date(theForm.dropoffMonthYear.options[theForm.dropoffMonthYear.selectedIndex].value.substr(2,4),theForm.dropoffMonthYear.options[theForm.dropoffMonthYear.selectedIndex].value.substr(0,2)-1,theForm.dDay.options[theForm.dDay.selectedIndex].value);
if (pickupdate >= dropoffdate)
	{alert("Drop-off day must be later than the Pick-up date.");
	theForm.pickupMonthYear.focus();
	return false;}
}