hotelfindersubmitcount=0;

function VerifyCarCat() {
var f = document.hotelfinder;
var c = f.Island;
var area = c.value.match(/^[a-zA-Z\s]+/);
var island = area ? area[0] : "";
if (island == "" || island == "XX") {
	return abort(c, "You must select an island for your stay.");
}
c = f.Car_Option;
var carcat = parseInt(c.value, 10);
carcat = isNaN(carcat) ? 0 : Math.round(carcat);
if (carcat <0) carcat = 0;
if (carcat > 17) carcat = 17;
if (carcat == 0) return true;

if (island == "Oahu") return true;
if (island == "Maui") return true;
if (island == "Molokai") {
	if ((1<carcat && carcat<6) || carcat==7 || carcat==8 || carcat==10)
		return true;
	else return abort(c, "This car category is not available on Molokai. Please choose another kind of car.");
}
if (island == "Kauai") {
	if (carcat != 15 && carcat != 16) return true;
	else return abort(c, "This car category is not available on Kauai. Please choose another kind of car.");
}
if (island == "Big Island") {
	if (carcat != 15 && carcat != 16) return true;
	else return abort(c, "This car category is not available on the Big Island. Please choose another kind of car.");
}
if (island == "Lanai") return abort(c, "Please choose No Car Please if you are staying on Lanai. Cars are not generally available there.");
return true;
} // function VerifyCarCat

function hotelfindervalidate(fob) {

	var f = fob || document.forms.hotelfinder;
//window.alert("hotelfindervalidate fob = "+fob);
//window.alert("hotelfindervalidate dealing with f.toString() of "+f.toString());
	var c,m,v;
	var daysout = 1; // days of lead time required (from today)
	var maxlength = 60; // days of max rental

// <SELECT NAME="Island">

	v = sval(c=f.Island);
	if (v == "XX") return abort(c,"You must select an island in the \"Island/Area\" pulldown menu. Please select and Island and/or Area you desire and hit the \"Find My Hotel\" button again.");

    msg = "The checkin date you have selected is not valid.";
    var cidate = CheckDate(f.date1); // Check In Date
    if (!cidate) return abort(f.date1, msg);

    var syyyy = cidate.getFullYear();
    var smm = 1 + cidate.getMonth();
    var sdd = cidate.getDate();

    msg = "The checkout date you have selected is not valid.";
    var codate = CheckDate(f.date2); // Check Out Date
    if (!codate) return abort(f.date2,msg);

    var eyyyy = codate.getFullYear();
    var emm = 1 + codate.getMonth();
    var edd = codate.getDate();

	msg = "Check-in date must be at least "+daysout+" days in the future, please check it.";
	var startdaysout = days_in_future(syyyy, smm, sdd);
	if (startdaysout <daysout) return abort(f.date1, msg);

	msg = "Check-out date must be on or after the check-in date, please check it.";
	var enddaysout = days_in_future(eyyyy, emm, edd);
	if (enddaysout <startdaysout) return abort(f.date2, msg);

	msg = "Check out date must be within "+maxlength+" days of check in date, please check it.";
	if (startdaysout + maxlength <enddaysout) return abort(f.date2, msg);

	if (VerifyChildren(f)) ; else return false;
	//if (VerifyCarCat()) ; else return false;

    //Check for multiple clicking of submit button:
    if (hotelfindersubmitcount > 0) {
        window.alert("We are in the process of finding the hotels you specified. Please be patient. If you cannot seem to get beyond this page, please reload this page and try again.");
        return false;
    }
    ++hotelfindersubmitcount;
    return true;
} // function hotelfindervalidate
