//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = 31;
  if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;
  if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{
  DaysObject = eval("document.form." + Which + "Day");
  MonthObject = eval("document.form." + Which + "Month");
  YearObject = eval("document.form." + Which + "Year");

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which)
{
  DaysObject = eval("document.form." + Which + "Day");
  MonthObject = eval("document.form." + Which + "Month");
  YearObject = eval("document.form." + Which + "Year");
  
  NowYear = NowYear - 2000 ; 

  YearObject[NowYear].selected = true;
  MonthObject[NowMonth].selected = true;

  ChangeOptionDays(Which);

  DaysObject[NowDay-1].selected = true;
}





























var currentDate = new Date();

function checkForm() {

	if (document.form.AreaId.value==66666) {

			alert("Please select a Location");

			return false;

			}

	if (document.form.groupId.value==77777) {

			alert("Please select a Vehicle type");

			return false;

			}

	if (document.form.AreaId.value==1) {

		if (document.form.groupId.value==29) {

			alert("Sorry,  This Vehicle type (7. Full Size Automatic 4 Door) is only available in the Republic of Ireland");

			return false;

			}

if (document.form.groupId.value==31) {

			alert("Sorry,  This Vehicle type (9. Minibus) is only available in the Republic of Ireland");

			return false;

			}

		if (document.form.groupId.value==33) {

			alert("Sorry,  This Vehicle type (12. Luxury Full Size 4 Door) is only available in the Republic of Ireland");

			return false;

			}

		}

	if (document.form.AreaId.value==9) {

		if (document.form.groupId.value==29) {

			alert("Sorry,  This Vehicle type (7. Full Size Automatic 4 Door) is only available in the Republic of Ireland");

			return false;

			}

		if (document.form.groupId.value==31) {

			alert("Sorry,  This Vehicle type (9. Minibus) is only available in the Republic of Ireland");

			return false;

			}

		if (document.form.groupId.value==33) {

			alert("Sorry,  This Vehicle type (12. Luxury Full Size 4 Door) is only available in the Republic of Ireland");

			return false;

			}

		}

	if (document.form.AreaId.value==15) {

		if (document.form.groupId.value==29) {

			alert("Sorry,  This Vehicle type (7. Full Size Automatic 4 Door) is only available in the Republic of Ireland");

			return false;

			}

		if (document.form.groupId.value==31) {

			alert("Sorry,  This Vehicle type (9. Minibus) is only available in the Republic of Ireland");

			return false;

			}

		if (document.form.groupId.value==33) {

			alert("Sorry,  This Vehicle type (12. Luxury Full Size 4 Door) is only available in the Republic of Ireland");

			return false;

			}

		}

	var currentDate = new Date();

	var startDate = new Date(document.form.Year.selectedIndex+2000, document.form.Month.selectedIndex, document.form.Day.selectedIndex+1);

var Date2 = new Date(2002, 11, 28);
var Date1 = new Date(2002, 11, 23);

	if ((startDate <= Date2) && (startDate >= Date1)) {
		alert("We have no cars available for the dates you have selected. Please try another date.");
		return false;
		}
	

	if (startDate <= currentDate) {

		alert("The Start Date you select must be after todays date");

		return false;

		}




	if (document.form.DaysHire.value=="") {

		alert("\nYou must enter the number of days within the rental period.");

		return false;

		}

	else {

		var noDays = document.form.DaysHire.value;

		var isError = 0;

		for (i=0;i<noDays.length;i++) {

			letter = noDays.substring(i,i+1);

			if (letter<'0' || letter>'9') {

				alert("\nThe Number of Days rental figure appears to be invalid");

				return false;

				}

			}

		if (eval(noDays)<1) {

			alert("You must enter a valid number of days within the rental period.");

			return false;

			}

		}

	return true;

	}

	












function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

























