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 = "出発地の空港をお選びください。";
    if (c = f.Origin_Airport) {
        v = sval(c);
        if (v == "XX") return abort(c, msg);
    }
    msg = "到着地の空港をお選びください。";
    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 = "出発日の設定が正しくありません。";
    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 = "到着日の設定が正しくありません。";
    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 = "出発日は少なくとも "+daysout+" 日間先の日を入力して下さい。";
	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 = "少なくとも大人１人をお選びください。";
        if (totalpax <1) return abort(c, msg);
    }
    if (c = f.Num_Children) {
        totalpax += nval(c);
        msg = "合計で6人以下になるようにしてください。";
        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("お客様の設定に基づいて、ただ今航空運賃の確認をしております。しばらくお待ちください。もしこのページが凍結してしまった場合は、恐れ入りますが上部メニューの更新ボタンを押して、もう一度お試しください。");
        return false;
    }
    ++airavailsubmitcount;
    return true;
}
