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, "滞在先の島を選択して下さい。");
}
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, "こちらの車種はモロカイ島ではご利用になれません。他の車種を選択して下さい。");
}
if (island == "Kauai") {
	if (carcat != 15 && carcat != 16) return true;
	else return abort(c, "こちらの車種はカウアイ島ではご利用になれません。他の車種を選択して下さい。");
}
if (island == "Big Island") {
	if (carcat != 15 && carcat != 16) return true;
	else return abort(c, "こちらの車種はハワイ島ではご利用になれません。他の車種を選択して下さい。");
}
if (island == "Lanai") return abort(c, "ラナイ島に滞在される場合には、「車を利用しない」を選択して下さい。ラナイ島では、通常レンタカーを借りる事は出来ません。");
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,"メニューから_Island/Area_を選択して下さい。島か場所を選択し、もう一度_Find My Hotel_ボタンを押して下さい。");

    msg = "チェックインの日付の設定が正しくありません。";
    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 = "チェックアウトの日付の設定が正しくありません。";
    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 = "チェックインの日は最低 "+daysout+" 日間先の日を入力して下さい。";
	var startdaysout = days_in_future(syyyy, smm, sdd);
	if (startdaysout <daysout) return abort(f.date1, msg);

	msg = "チェックアウトの日は、チェックイン当日かそれ以降の日からとなります。お確かめ下さい。";
	var enddaysout = days_in_future(eyyyy, emm, edd);
	if (enddaysout <startdaysout) return abort(f.date2, msg);

	msg = "チェックアウトの日は "+maxlength+" 日以内からとなります。ご確認下さい。";
	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("只今、お客様の選択されたホテルを検索中です。もうしばらくお待ち下さい。但しこのページから先へ進まない場合には、もう一度更新し、初めからやり直して下さい。");
        return false;
    }
    ++hotelfindersubmitcount;
    return true;
} // function hotelfindervalidate
