
function val_reservation(theForm)
{
//==================================================================================================================
//--tests for if 2 digit or 4 digit year value entered--
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
//--tests for if 2 digit or 4 digit year value entered--
//==================================================================================================================

var startdate = theForm.pickupdate.value
var dates  = parseFloat(startdate.substring(0,2));
var months = startdate.substring(3,6);
var years  = parseFloat(startdate.substring(7,11));

switch (months) {
   case "JAN":
      months=1
      break
   case "FEB":
      months=2
      break
   case "MAR":
      months=3
      break
   case "APR":
      months=4
      break
   case "MAY":
      months=5
      break
   case "JUN":
      months=6
      break
   case "JUL":
      months=7
      break
   case "AUG":
      months=8
      break
   case "SEP":
      months=9
      break
   case "OCT":
      months=10
      break
   case "NOV":
      months=11
      break
   case "DEC":
      months=12
      break
   default:
     document.write("Invalid Weekday<BR>\n")
     break
}

var pickupdate = new Date(years,parseFloat(months)-1,dates)
//-------------------------------------------------------------------
var startdate1 = theForm.returndate.value
var dates1  = parseFloat(startdate1.substring(0,2));
var months1 = startdate1.substring(3,6);
var years1  = parseFloat(startdate1.substring(7,11));

switch (months1) {
   case "JAN":
      months1=1
      break
   case "FEB":
      months1=2
      break
   case "MAR":
      months1=3
      break
   case "APR":
      months1=4
      break
   case "MAY":
      months1=5
      break
   case "JUN":
      months1=6
      break
   case "JUL":
      months1=7
      break
   case "AUG":
      months1=8
      break
   case "SEP":
      months1=9
      break
   case "OCT":
      months1=10
      break
   case "NOV":
      months1=11
      break
   case "DEC":
      months1=12
      break
   default:
     document.write("Invalid Weekday<BR>\n")
     break
}

var returndate = new Date(years1,parseFloat(months1)-1,dates1)
//-------------------------------------------------------------------
var starttime = Date.UTC(y2k(pickupdate.getYear()),pickupdate.getMonth(),pickupdate.getDate(),0,0,0);
var endtime = Date.UTC(y2k(returndate.getYear()),returndate.getMonth(),returndate.getDate(),0,0,0);

//==================================================================================================================
//ACTUAL VALIDATION
//==================================================================================================================
if (starttime > endtime) {

   alert("Pickup Date: " + startdate + " is more than Return Date: " + startdate1);
   return false    
}
  
 if (theForm.CatKey.selectedIndex == 0)
  {
    alert("Please choose car type");
    theForm.CatKey.focus();
    return (false);
  }

 if (theForm.ModelID.selectedIndex == 0)
  {
    alert("Please choose model");
    theForm.ModelID.focus();
    return (false);
  }

if (theForm.pickupdate.value == "")
  {
    alert("Please select picup date");
    theForm.pickupdate.focus();
    return (false);
  }
  

return (true);
}


//=====================================================
function val_findrates(theForm)
{

 if (theForm.FRCatKey.selectedIndex == 0)
  {
    alert("TO FIND RATES\n____________________________\n\nPlease choose car type");
    theForm.FRCatKey.focus();
    return (false);
  }

 if (theForm.FRRates.selectedIndex == 0)
  {
    alert("TO FIND RATES\n____________________________\n\nPlease choose rates");
    theForm.FRRates.focus();
    return (false);
  }
return (true);
}
