airavailsubmitcount=0;

function airavailvalidate(fob) {

    var f = fob || document.forms.airavail;
	var c,msg;
	var daysout = 1; // days of lead time required (from today)

// Check that Origin and Destination are entered

    msg = "Please select an Origin (starting) airport";
    if (c = f.Origin_Airport) {
        v = sval(c);
        if (v == "XX") return abort(c, msg);
    }
    msg = "Please select a destination airport";
    if (c = f.Hawaii_Airport) {
        v = sval(c);
        if (v == "XX") return abort(c, msg);
    }

    msg = "Please enter a departure date";
    if (c = f.airdate1) {
        v = sval(c);
        if (v == "") return abort(c, msg);
    }

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

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

    msg = "Please enter a return date";
    if (c = f.airdate2) {
        v = sval(c);
        if (v == "") return abort(c, msg);
    }

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

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

	msg = "Departure 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.airdate1, msg);

	msg = "Return date must be after the departure date, please check it.";
	var enddaysout = days_in_future(eyyyy, emm, edd);
	if (enddaysout <= startdaysout) return abort(f.airdate2, msg);

    var totalpax = 0;

    if (c = f.Num_Adults) {
        totalpax += nval(c);
        msg = "You must select at least one adult passenger.";
        if (totalpax <1) return abort(c, msg);
    }
    if (c = f.Num_Children) {
        totalpax += nval(c);
        msg = "You must select six or fewer passengers total.";
        if (6 <totalpax) return abort(c, msg);
    }

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

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