﻿
function pageReLoad(elementId) {
    if ($get(elementId + "_TourPattern0").checked) {
        $get(elementId + "_PanelAir").style.display = "block";
        $get(elementId + "_PanelMsgPtn0").style.display = "block";
        $get(elementId + "_PanelMsgPtn1").style.display = "none";
        $get(elementId + "_PanelMsgPtn2").style.display = "none";
        $get(elementId + "_PanelRentCar").style.display = "none";


        $get(elementId + "_plan1Image").style.display = "block";
        $get(elementId + "_plan2Image").style.display = "none";
        $get(elementId + "_plan3Image").style.display = "none";
    }
    else if ($get(elementId + "_TourPattern1").checked) {
        $get(elementId + "_PanelAir").style.display = "block";
        $get(elementId + "_PanelRentCar").style.display = "block";
        $get(elementId + "_PanelMsgPtn1").style.display = "block";
        $get(elementId + "_PanelRentLink1").style.display = "none";
        //        $get(elementId + "_PanelRentLinkA1").style.display = "none";
        $get(elementId + "_PanelMsgPtn0").style.display = "none";
        $get(elementId + "_PanelMsgPtn2").style.display = "none";
        $get(elementId + "_PanelRentTtl").style.display = "none";
        $get(elementId + "_PanelRentArea").style.display = "block";
        $get(elementId + "_PanelRentLink2").style.display = "block";
        $get(elementId + "_PanelRentLinkB1").style.display = "block";
        $get(elementId + "_PanelRentLinkB2").style.display = "none";
        $get(elementId + "_PanelRetTtl").style.display = "none";
        $get(elementId + "_PanelRetArea").style.display = "none";
        $get(elementId + "_PanelCarOp").style.display = "none";
        $get(elementId + "_PanelCarOp2").style.display = "none";
        $get(elementId + "_PanelCarOp1").style.display = "block";

        $get(elementId + "_plan1Image").style.display = "none";
        $get(elementId + "_plan2Image").style.display = "block";
        $get(elementId + "_plan3Image").style.display = "none";
    }
    else {
        $get(elementId + "_PanelRentCar").style.display = "block";
        $get(elementId + "_PanelMsgPtn2").style.display = "block";
        $get(elementId + "_PanelRentLink2").style.display = "block";
        $get(elementId + "_PanelRentLinkB1").style.display = "block";
        $get(elementId + "_PanelRentArea").style.display = "block";
        $get(elementId + "_PanelMsgPtn0").style.display = "none";
        $get(elementId + "_PanelMsgPtn1").style.display = "none";
        $get(elementId + "_PanelAir").style.display = "none";
        $get(elementId + "_PanelRentLink1").style.display = "none";
        $get(elementId + "_PanelRentLinkB2").style.display = "none";
        $get(elementId + "_PanelRentTtl").style.display = "none";
        $get(elementId + "_PanelRetTtl").style.display = "none";
        $get(elementId + "_PanelRetArea").style.display = "none";
        $get(elementId + "_PanelCarOp").style.display = "none";
        $get(elementId + "_PanelCarOp2").style.display = "none";
        $get(elementId + "_PanelCarOp1").style.display = "block";

        $get(elementId + "_plan1Image").style.display = "none";
        $get(elementId + "_plan2Image").style.display = "none";
        $get(elementId + "_plan3Image").style.display = "block";
    }
}

// 予約区分ラジオボタン選択
function ReserveKbnRadioButtonOnClick(radio, searchId, goArrDropDownList, airlineId) {
    var elementId = radio.id.slice(0, radio.id.lastIndexOf("_"));

    callSearchId = searchId;

    // Webサービスを呼び出す。
    switch (searchId) {
        case "PFSPS010":
            if (radio.id.indexOf("TourPattern0") >= 0)
                JTB.RTP.Front.Web.UI.Search.PFSPS010WebService.TourPattern0_CheckedChanged("0", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);
            else if (radio.id.indexOf("TourPattern1") >= 0)
                JTB.RTP.Front.Web.UI.Search.PFSPS010WebService.TourPattern1_CheckedChanged("1", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);
            else
                JTB.RTP.Front.Web.UI.Search.PFSPS010WebService.TourPattern2_CheckedChanged("2", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);
            break;
        case "PFSPS011":
            if (radio.id.indexOf("TourPattern0") >= 0) {
                JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.TourPattern0_CheckedChanged("0", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);

                $get(elementId + "_plan1Image").style.display = "block";
                $get(elementId + "_plan2Image").style.display = "none";
                $get(elementId + "_plan3Image").style.display = "none";
                //                $get(elementId + "_GoTimeDefinitionList").style.display = "block";
                //                $get(elementId + "_ReTimeDefinitionList").style.display = "block";

                // 到着空港ドロップダウン変更イベントを呼び出す
                DropDownListGoArrOnChange(goArrDropDownList, airlineId);

            }
            else if (radio.id.indexOf("TourPattern1") >= 0) {
                JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.TourPattern1_CheckedChanged("1", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);

                $get(elementId + "_plan1Image").style.display = "none";
                $get(elementId + "_plan2Image").style.display = "block";
                $get(elementId + "_plan3Image").style.display = "none";
                //                $get(elementId + "_GoTimeDefinitionList").style.display = "block";
                //                $get(elementId + "_ReTimeDefinitionList").style.display = "block";

                SetRentACarDropDownList(elementId);

                // 到着空港ドロップダウン変更イベントを呼び出す
                DropDownListGoArrOnChange(goArrDropDownList, airlineId);

            }
            else {
                //JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.TourPattern2_CheckedChanged("2", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);
                JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.TourPattern2_CheckedChanged("2", TourPattern2RadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);

                $get(elementId + "_plan1Image").style.display = "none";
                $get(elementId + "_plan2Image").style.display = "none";
                $get(elementId + "_plan3Image").style.display = "block";
                //                $get(elementId + "_GoTimeDefinitionList").style.display = "none";
                //                $get(elementId + "_ReTimeDefinitionList").style.display = "none";

                SetRentACarDropDownList(elementId);
            }
            break;
        case "PFSPS012":
            if (radio.id.indexOf("TourPattern0") >= 0)
                JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS012WebService.TourPattern0_CheckedChanged("0", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);
            else if (radio.id.indexOf("TourPattern1") >= 0)
                JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS012WebService.TourPattern1_CheckedChanged("1", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);
            else
                JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS012WebService.TourPattern2_CheckedChanged("2", ReserveKbnRadioButtonOnSuccess, ReserveKbnRadioButtonOnFailed, radio);
            break;
        default:
            break;
    }
}

// 予約区分ラジオボタン選択成功コールバック
function ReserveKbnRadioButtonOnSuccess(result, userContext, methodName) {
    var elementId = userContext.id.slice(0, userContext.id.lastIndexOf("_"));
    // 出発日
    if ((result.StartDate != null) && (result.StartDate.length > 0)) {
        SetDropDownData($get(elementId + "_StartDate"), result.StartDate, result.StartDateSelectedIndex);
    }
    // 到着日
    if ((result.EndDate != null) && (result.EndDate.length > 0)) {
        SetDropDownData($get(elementId + "_EndDate"), result.EndDate, result.EndDateSelectedIndex);
    }
    //チェックボックス変更不可
    $get(elementId + "_OtherStayCheckBox").checked = false;
    $get(elementId + "_OtherStayCheckBox").setAttribute("disabled", "disabled");
    if ($get(elementId + "_OtherStayCheckBox").parentElement)
        $get(elementId + "_OtherStayCheckBox").parentElement.setAttribute("disabled", "disabled");

    pageReLoad(elementId);
}

// add 2011/04/21
// 宿＋レンタカーラジオボタン選択成功コールバック
function TourPattern2RadioButtonOnSuccess(result, userContext, methodName) {
    var elementId = userContext.id.slice(0, userContext.id.lastIndexOf("_"));
    // 出発日
    if ((result.StartDate != null) && (result.StartDate.length > 0)) {
        SetDropDownData($get(elementId + "_StartDate"), result.StartDate, result.StartDateSelectedIndex);
    }
    // 到着日
    if ((result.EndDate != null) && (result.EndDate.length > 0)) {
        SetDropDownData($get(elementId + "_EndDate"), result.EndDate, result.EndDateSelectedIndex);
    }
    //チェックボックス変更不可
    $get(elementId + "_OtherStayCheckBox").checked = false;
    $get(elementId + "_OtherStayCheckBox").setAttribute("disabled", "disabled");
    if ($get(elementId + "_OtherStayCheckBox").parentElement)
        $get(elementId + "_OtherStayCheckBox").parentElement.setAttribute("disabled", "disabled");

    // 宿泊12エリアコード
    if (result.HotelArea != null) {
        $get(elementId + "_HotelArea").value = result.HotelArea;
    }
    // 宿泊地域
    if ((result.HotelKen != null) && (result.HotelKen.length > 0)) {
        SetDropDownData($get(elementId + "_HotelKen"), result.HotelKen, result.HotelKenSelectedIndex);
        // 地図更新を呼び出す。
        if (window.SupportMap != undefined) {
            SupportMap.write();
        }
    }
    // 宿泊地区
    if ((result.HotelSubArea != null) && (result.HotelSubArea.length > 0)) {
        SetDropDownData($get(elementId + "_HotelSubArea"), result.HotelSubArea, result.HotelSubAreaSelectedIndex);
    }
    // 宿泊詳細地区
    if ((result.HotelMesh != null) && (result.HotelMesh.length > 0)) {
        SetDropDownData($get(elementId + "_HotelMesh"), result.HotelMesh, result.HotelMeshSelectedIndex);

        if ((result.HotelSubArea == null) || (result.HotelSubArea.length == 0)) {
            // 宿泊地区に変更がかかったため、貸出レンタカー地区・店舗、返却レンタカー地区・店舗も同様に変更
            var hotelSubAreaDropDown = $get(elementId + "_HotelSubArea");
            var rentalSubAreaDropDown = $get(elementId + "_RentalSubArea");
            var rentalOfficeDropDown = $get(elementId + "_RentalOffice");
            var returnSubAreaDropDown = $get(elementId + "_ReturnSubArea");
            var returnOfficeDropDown = $get(elementId + "_ReturnOffice");
            var selectedValue = hotelSubAreaDropDown.options[hotelSubAreaDropDown.selectedIndex].value;

            var isFound = false;
            if ((rentalSubAreaDropDown != null) && (rentalOfficeDropDown != null)) {
                for (var i = 0; i < rentalSubAreaDropDown.options.length; i++) {
                    if (rentalSubAreaDropDown.options[i].value == selectedValue) {
                        // 貸出レンタカー地区・店舗を再取得
                        rentalSubAreaDropDown.selectedIndex = i;
                        DropDownListRentalSubAreaOnChange(rentalSubAreaDropDown, callSearchId);
                        isFound = true;
                        break;
                    }
                }
            }
            isFound = false;
            if ((returnSubAreaDropDown != null) && (returnOfficeDropDown != null)) {
                for (var i = 0; i < returnSubAreaDropDown.options.length; i++) {
                    if (returnSubAreaDropDown.options[i].value == selectedValue) {
                        // 返却レンタカー地区・店舗を再取得
                        returnSubAreaDropDown.selectedIndex = i;
                        DropDownListReturnSubAreaOnChange(returnSubAreaDropDown, callSearchId);
                        isFound = true;
                        break;
                    }
                }
            }
        }
    }
    // 貸出レンタカー地域
    if ((result.RentalKen != null) && (result.RentalKen.length > 0)) {
        SetDropDownData($get(elementId + "_RentalKen"), result.RentalKen, result.RentalKenSelectedIndex);
    }
    // 貸出レンタカー地区
    if ((result.RentalSubArea != null) && (result.RentalSubArea.length > 0)) {
        SetDropDownData($get(elementId + "_RentalSubArea"), result.RentalSubArea, result.RentalSubAreaSelectedIndex);
    }
    // 貸出レンタカー店舗
    if ((result.RentalOffice != null) && (result.RentalOffice.length > 0)) {
        SetDropDownData($get(elementId + "_RentalOffice"), result.RentalOffice, result.RentalOfficeSelectedIndex);

        if ((result.RentalSubArea == null) || (result.RentalSubArea.length == 0)) {
            // 貸出レンタカー地区に変更がかかったため、返却レンタカー地区・店舗も同様に変更
            var rentalSubAreaDropDown = $get(elementId + "_RentalSubArea");
            var returnSubAreaDropDown = $get(elementId + "_ReturnSubArea");
            var returnOfficeDropDown = $get(elementId + "_ReturnOffice");
            var selectedValue = rentalSubAreaDropDown.options[rentalSubAreaDropDown.selectedIndex].value;

            var isFound = false;
            if ((returnSubAreaDropDown != null) && (returnOfficeDropDown != null)) {
                for (var i = 0; i < returnSubAreaDropDown.options.length; i++) {
                    if (returnSubAreaDropDown.options[i].value == selectedValue) {
                        // 返却レンタカー地区・店舗を再取得
                        returnSubAreaDropDown.selectedIndex = i;
                        DropDownListReturnSubAreaOnChange(returnSubAreaDropDown, callSearchId);
                        isFound = true;
                        break;
                    }
                }
                if (!isFound) {
                    returnSubAreaDropDown.selectedIndex = 0;
                    returnOfficeDropDown.selectedIndex = 0;
                }
            }
        }
    }
    // 返却レンタカー地域
    if ((result.ReturnKen != null) && (result.ReturnKen.length > 0)) {
        SetDropDownData($get(elementId + "_ReturnKen"), result.ReturnKen, result.ReturnKenSelectedIndex);
    }
    // 返却レンタカー地区
    if ((result.ReturnSubArea != null) && (result.ReturnSubArea.length > 0)) {
        SetDropDownData($get(elementId + "_ReturnSubArea"), result.ReturnSubArea, result.ReturnSubAreaSelectedIndex);
    }
    // 返却レンタカー店舗
    if ((result.ReturnOffice != null) && (result.ReturnOffice.length > 0)) {
        SetDropDownData($get(elementId + "_ReturnOffice"), result.ReturnOffice, result.ReturnOfficeSelectedIndex);
    }

    pageReLoad(elementId);
}
// add end

// 予約区分ラジオボタン選択失敗コールバック
function ReserveKbnRadioButtonOnFailed(error, userContext, methodName) { }

// 出発日ドロップダウン変更
function DropDownListStartDateOnChange(dropdown) {
    var elementId = dropdown.id.slice(0, dropdown.id.lastIndexOf("_"));
    var endData = $get(elementId + "_EndDate");
    if (dropdown.selectedIndex + 1 < dropdown.length) {
        endData.selectedIndex = dropdown.selectedIndex + 1;
    }
    else {
        endData.selectedIndex = dropdown.selectedIndex;
    }
    //チェックボックス変更不可
    $get(elementId + "_OtherStayCheckBox").checked = false;
    $get(elementId + "_OtherStayCheckBox").setAttribute("disabled", "disabled");
    if ($get(elementId + "_OtherStayCheckBox").parentElement)
        $get(elementId + "_OtherStayCheckBox").parentElement.setAttribute("disabled", "disabled");
}

// 帰着日ドロップダウン変更
function DropDownListEndDateOnChange(dropdown) {
    var elementId = dropdown.id.slice(0, dropdown.id.lastIndexOf("_"));
    var startData = $get(elementId + "_StartDate");

    if (dropdown.selectedIndex - startData.selectedIndex > 1) {
        //チェックボックス変更可
        $get(elementId + "_OtherStayCheckBox").removeAttribute("disabled");
        if ($get(elementId + "_OtherStayCheckBox").parentElement)
            $get(elementId + "_OtherStayCheckBox").parentElement.removeAttribute("disabled");
    }
    else {
        $get(elementId + "_OtherStayCheckBox").checked = false;
        $get(elementId + "_OtherStayCheckBox").setAttribute("disabled", "disabled");
        if ($get(elementId + "_OtherStayCheckBox").parentElement)
            $get(elementId + "_OtherStayCheckBox").parentElement.setAttribute("disabled", "disabled");
    }
}

// 2010/11/22 STEP3 ADD  miura START
// 航空会社変更
function RadioButtonAirlineSelectOnChange(radiobutton, airOfficeKbn, goDep) {
    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.Airline_SelectedChanged(airOfficeKbn, goDep, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, radiobutton);
}
// 2010/11/22 STEP3 ADD  miura END

// 出発空港ドロップダウン変更
//function DropDownListGoDepOnChange(dropdown) {    // 2010/12/10 STEP3 MIURA MOD
function DropDownListGoDepOnChange(dropdown, airOfficeKbn) {
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.GoDep_SelectedIndexChanged(airOfficeKbn, selectedValue, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 到着空港ドロップダウン変更
//function DropDownListGoArrOnChange(dropdown) {    // 2010/12/10 STEP3 MIURA MOD
function DropDownListGoArrOnChange(dropdown, airOfficeKbn) {
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.GoArr_SelectedIndexChanged(airOfficeKbn, selectedValue, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 復路出発空港ドロップダウン変更
function DropDownListReDepOnChange(dropdown) {
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.ReDep_SelectedIndexChanged(selectedValue, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 宿泊地域ドロップダウン変更
function DropDownListHotelKenOnChange(dropdown) {
    var elementId = dropdown.id.slice(0, dropdown.id.lastIndexOf("_"));
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;

    var reserveKbn = null;
    if ($get(elementId + "_TourPattern0").checked) reserveKbn = "0";
    if ($get(elementId + "_TourPattern1").checked) reserveKbn = "1";
    if ($get(elementId + "_TourPattern2").checked) reserveKbn = "2";

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.HotelKen_SelectedIndexChanged(selectedValue, reserveKbn, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 宿泊地区ドロップダウン変更
function DropDownListHotelSubAreaOnChange(dropdown) {
    var elementId = dropdown.id.slice(0, dropdown.id.lastIndexOf("_"));
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;
    if (selectedValue == "") return;
    var reserveKbn = null;
    if ($get(elementId + "_TourPattern0").checked) reserveKbn = "0";
    if ($get(elementId + "_TourPattern1").checked) reserveKbn = "1";
    if ($get(elementId + "_TourPattern2").checked) reserveKbn = "2";

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.HotelSubArea_SelectedIndexChanged(selectedValue, reserveKbn, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 貸出レンタカー地域ドロップダウン変更
function DropDownListRentalKenOnChange(dropdown) {
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;

    var rentalKenDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_RentalKen");
    var returnKenDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_ReturnKen");
    returnKenDropDown.selectedIndex = rentalKenDropDown.selectedIndex;

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.RentalKen_SelectedIndexChanged(selectedValue, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 貸出レンタカー地区ドロップダウン変更
function DropDownListRentalSubAreaOnChange(dropdown) {

    var rentalKenDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_RentalKen");
    var rentalSubAreaDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_RentalSubArea");
    var selectedValue1 = rentalKenDropDown.options[rentalKenDropDown.selectedIndex].value;
    var selectedValue2 = dropdown.options[dropdown.selectedIndex].value;

    var returnKenDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_ReturnKen");
    var returnSubAreaDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_ReturnSubArea");
    var returnKen = returnKenDropDown.options[returnKenDropDown.selectedIndex].value;
    var flg = "0";

    if (selectedValue1 == returnKen) {
        returnSubAreaDropDown.selectedIndex = rentalSubAreaDropDown.selectedIndex;
    }
    else {
        flg = "1";
    }


    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.RentalSubArea_SelectedIndexChanged(selectedValue1, selectedValue2, flg, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 貸出レンタカー店舗ドロップダウン変更
function DropDownListRentalOfficeOnChange(dropdown) {
    var returnOfficeDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_ReturnOffice");
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;

    if (returnOfficeDropDown != null) {
        returnOfficeDropDown.selectedIndex = 0;
        for (var i = 0; i < returnOfficeDropDown.options.length; i++) {
            if (returnOfficeDropDown.options[i].value == selectedValue) {
                returnOfficeDropDown.selectedIndex = i;
                break;
            }
        }
    }
}

// 返却レンタカー地域ドロップダウン変更
function DropDownListReturnKenOnChange(dropdown) {
    var selectedValue = dropdown.options[dropdown.selectedIndex].value;

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.ReturnKen_SelectedIndexChanged(selectedValue, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 返却レンタカー地区ドロップダウン変更
function DropDownListReturnSubAreaOnChange(dropdown) {
    var returnKenDropDown = $get(dropdown.id.slice(0, dropdown.id.lastIndexOf("_")) + "_ReturnKen");
    var selectedValue1 = returnKenDropDown.options[returnKenDropDown.selectedIndex].value;
    var selectedValue2 = dropdown.options[dropdown.selectedIndex].value;

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.ReturnSubArea_SelectedIndexChanged(selectedValue1, selectedValue2, GetSearchDropDownDataOnSuccess, GetSearchDropDownDataOnFailed, dropdown);
}

// 予約区分ラジオボタン選択失敗コールバック
function ReserveKbnRadioButtonOnFailed(error, userContext, methodName) { }

// 検索条件ドロップダウン取得成功コールバック
function GetSearchDropDownDataOnSuccess(result, userContext, methodName) {
    var elementId = userContext.id.slice(0, userContext.id.lastIndexOf("_"));
    // 2010/11/24 STEP3 miura ADD START
    // 出発空港
    if ((result.DepAir != null) && (result.DepAir.length > 0)) {
        SetDropDownData($get(elementId + "_GoDep"), result.DepAir, result.DepAirSelectedIndex);
    }
    // 2010/11/24 STEP3 miura ADD START
    // 到着空港
    if ((result.ArrAir != null) && (result.ArrAir.length > 0)) {
        SetDropDownData($get(elementId + "_GoArr"), result.ArrAir, result.ArrAirSelectedIndex);
    }
    // 復路出発空港
    if ((result.ReDepAir != null) && (result.ReDepAir.length > 0)) {
        SetDropDownData($get(elementId + "_ReDep"), result.ReDepAir, result.ReDepAirSelectedIndex);
    }
    // 復路到着空港
    if ((result.ReArrAir != null) && (result.ReArrAir.length > 0)) {
        SetDropDownData($get(elementId + "_ReArr"), result.ReArrAir, result.ReArrAirSelectedIndex);
    }

    // 宿泊地域
    if ((result.HotelKen != null) && (result.HotelKen.length > 0)) {
        SetDropDownData($get(elementId + "_HotelKen"), result.HotelKen, result.HotelKenSelectedIndex);

        var reDepDropDown = $get(elementId + "_ReDep");
        var goArrDropDown = $get(elementId + "_GoArr");

        var optionLength = reDepDropDown.options.length;
        var selectedValue = goArrDropDown.options[goArrDropDown.selectedIndex].value;

        for (var i = 0; i < optionLength; i++) {
            if (reDepDropDown.options[i].value == selectedValue) {
                reDepDropDown.selectedIndex = i;
                break;
            }
        }

        // 地図更新を呼び出す。
        if (window.SupportMap != undefined) {
            SupportMap.write();
        }

    }
    // 宿泊地区
    if ((result.HotelSubArea != null) && (result.HotelSubArea.length > 0)) {
        SetDropDownData($get(elementId + "_HotelSubArea"), result.HotelSubArea, result.HotelSubAreaSelectedIndex);
    }
    // 貸出レンタカー地域
    if ((result.RentalKen != null) && (result.RentalKen.length > 0)) {
        SetDropDownData($get(elementId + "_RentalKen"), result.RentalKen, result.RentalKenSelectedIndex);
    }
    // 貸出レンタカー地区
    if ((result.RentalSubArea != null) && (result.RentalSubArea.length > 0)) {
        SetDropDownData($get(elementId + "_RentalSubArea"), result.RentalSubArea, result.RentalSubAreaSelectedIndex);
    }
    // 貸出レンタカー店舗
    if ((result.RentalOffice != null) && (result.RentalOffice.length > 0)) {
        SetDropDownData($get(elementId + "_RentalOffice"), result.RentalOffice, result.RentalOfficeSelectedIndex);
    }
    // 返却レンタカー地域
    if ((result.ReturnKen != null) && (result.ReturnKen.length > 0)) {
        SetDropDownData($get(elementId + "_ReturnKen"), result.ReturnKen, result.ReturnKenSelectedIndex);
    }
    // 返却レンタカー地区
    if ((result.ReturnSubArea != null) && (result.ReturnSubArea.length > 0)) {
        SetDropDownData($get(elementId + "_ReturnSubArea"), result.ReturnSubArea, result.ReturnSubAreaSelectedIndex);
    }
    // 返却レンタカー店舗
    if ((result.ReturnOffice != null) && (result.ReturnOffice.length > 0)) {
        SetDropDownData($get(elementId + "_ReturnOffice"), result.ReturnOffice, result.ReturnOfficeSelectedIndex);
    }
}

// 検索条件ドロップダウン取得失敗コールバック
function GetSearchDropDownDataOnFailed(error, userContext, methodName) {
    redirectErrorPage();
}

// ドロップダウン設定
function SetDropDownData(dropdown, data, selectedIndex) {

    // ドロップダウンが画面に存在しない場合は何もしない
    if (dropdown == null) return;

    // ドロップダウンをクリアしながら、新しいデータをセットする	
    var optionLength = dropdown.options.length;
    var dataLength = data.length;
    for (var i = 0; i < optionLength; i++) {
        if (i < dataLength) {
            dropdown.options[i].text = data[i].Text;
            if (data[i].Value != null)
                dropdown.options[i].value = data[i].Value;
            else
                dropdown.options[i].value = "";
        } else {
            dropdown.remove(dataLength);
        }
    }

    if (optionLength < dataLength) {
        for (var i = optionLength; i < dataLength; i++) {
            var opt = document.createElement("option");
            opt.text = data[i].Text;
            if (data[i].Value != null)
                opt.value = data[i].Value;
            else
                opt.value = "";
            var dummy;
            dropdown.add(opt, dummy);
        }
    }

    dropdown.selectedIndex = selectedIndex;
}

function SetDropDownIndex(dropdown1, dropdown2) {



}

// こども人数表示切替
function ChangeChildWindows(child) {
    var childPanel = $get(child);
    var elementId = child.slice(0, child.lastIndexOf("_"));
    if (childPanel != null) {
        if (childPanel.style.display == 'block') {
            childPanel.style.display = 'none';
            $get(elementId + "_ChildCountPanel2").style.display = 'none';
            $get(elementId + "_ChildCountPanel1").style.display = 'block';
        }
        else {
            childPanel.style.display = 'block';
            $get(elementId + "_ChildCountPanel2").style.display = 'block';
            $get(elementId + "_ChildCountPanel1").style.display = 'none';
        }
    }
}

// 航空表示切替
function ChangeReAir(air) {
    var reAirPanel = $get(air);
    var elementId = air.slice(0, air.lastIndexOf("_"));
    if (reAirPanel != null) {
        if (reAirPanel.style.display == 'block') {
            reAirPanel.style.display = 'none';
            $get(elementId + "_PanelReAir2").style.display = 'none';
            $get(elementId + "_PanelReAir1").style.display = 'block';
        }
        else {
            reAirPanel.style.display = 'block';
            $get(elementId + "_PanelReAir2").style.display = 'block';
            $get(elementId + "_PanelReAir1").style.display = 'none';
        }
    }
}

// レンタカーオプション表示切替
function ChangeRentA(rent) {
    var elementId = rent.slice(0, rent.lastIndexOf("_"));

    var rentTtlPanel = $get(elementId + "_PanelRentTtl");
    var rentAreaPanel = $get(elementId + "_PanelRentArea");
    var retTtlPanel = $get(elementId + "_PanelRetTtl");
    var retAreaPanel = $get(elementId + "_PanelRetArea");

    if (rentTtlPanel != null) {
        if (rentTtlPanel.style.display == 'block') {
            rentTtlPanel.style.display = 'none';
            rentAreaPanel.style.display = 'none';
            retTtlPanel.style.display = 'none';
            retAreaPanel.style.display = 'none';
            $get(elementId + "_PanelRentLinkA2").style.display = 'none';
            $get(elementId + "_PanelRentLinkA1").style.display = 'block';
        }
        else {
            rentTtlPanel.style.display = 'block';
            rentAreaPanel.style.display = 'block';
            retTtlPanel.style.display = 'block';
            retAreaPanel.style.display = 'block';
            $get(elementId + "_PanelRentLinkA2").style.display = 'block';
            $get(elementId + "_PanelRentLinkA1").style.display = 'none';
        }
    }
}

// レンタカーオプション表示切替
function ChangeRentB(rent) {
    var elementId = rent.slice(0, rent.lastIndexOf("_"));
    var retAreaPanel = $get(elementId + "_PanelRetArea");

    if (retAreaPanel != null) {
        if (retAreaPanel.style.display == 'block') {
            retAreaPanel.style.display = 'none';
            $get(elementId + "_PanelRentLinkB2").style.display = 'none';
            $get(elementId + "_PanelRentLinkB1").style.display = 'block';
        }
        else {
            retAreaPanel.style.display = 'block';
            $get(elementId + "_PanelRentLinkB2").style.display = 'block';
            $get(elementId + "_PanelRentLinkB1").style.display = 'none';
        }
    }
}

// レンタカーオプション表示切替
function ChangeCarOp(meal) {
    var elementId = meal.slice(0, meal.lastIndexOf("_"));
    var mealPanel = $get(elementId + "_PanelCarOp");
    if (mealPanel != null) {
        if (mealPanel.style.display == 'block') {
            mealPanel.style.display = 'none';
            $get(elementId + "_PanelCarOp2").style.display = 'none';
            $get(elementId + "_PanelCarOp1").style.display = 'block';
        }
        else {
            mealPanel.style.display = 'block';
            $get(elementId + "_PanelCarOp2").style.display = 'block';
            $get(elementId + "_PanelCarOp1").style.display = 'none';
        }
    }
}

// 食事表示切替
function ChangeMeal(meal) {
    var elementId = meal.slice(0, meal.lastIndexOf("_"));
    var mealPanel = $get(elementId + "_PanelMeal");
    if (mealPanel != null) {
        if (mealPanel.style.display == 'block') {
            mealPanel.style.display = 'none';
            $get(elementId + "_PanelMeal2").style.display = 'none';
            $get(elementId + "_PanelMeal1").style.display = 'block';
        }
        else {
            mealPanel.style.display = 'block';
            $get(elementId + "_PanelMeal2").style.display = 'block';
            $get(elementId + "_PanelMeal1").style.display = 'none';
        }
    }
}

// こども人数計算
function ChangeChildCount(dropdown) {
    var elementId = dropdown.id.slice(0, dropdown.id.lastIndexOf("_"));
    var childCountPanel2 = $get(elementId + "_ChildCountPanel2");
    if (childCountPanel2.style.display == 'block') {
        var countChildA = $get(elementId + "_CountChildA");
        var countChildB = $get(elementId + "_CountChildB");
        var countChildC = $get(elementId + "_CountChildC");
        var countChildD = $get(elementId + "_CountChildD");
        var countBaby = $get(elementId + "_CountBaby");
        var childCount = Number(countChildA.options[countChildA.selectedIndex].value)
            + Number(countChildB.options[countChildB.selectedIndex].value)
            + Number(countChildC.options[countChildC.selectedIndex].value)
            + Number(countChildD.options[countChildD.selectedIndex].value)
            + Number(countBaby.options[countBaby.selectedIndex].value);
        // ブラウザ判定
        if ($get(elementId + "_IcnArrowBoxLabel").textContent) {
            // 2011/05/10 1View対応 MOD S
            //$get(elementId + "_IcnArrowBoxLabel").textContent = "こども人数の設定（現在" + childCount + "名）";
            //$get(elementId + "_IcnArrowDownLabel").textContent = "こども人数の設定（現在" + childCount + "名）";
            // 2011/05/10 1View対応 MOD M
            $get(elementId + "_IcnArrowBoxLabel").textContent = "こども人数";
            $get(elementId + "_IcnArrowDownLabel").textContent = "こども人数";
            // 2011/05/10 1View対応 MOD E
        } else {
            // 2011/05/10 1View対応 MOD S
            //$get(elementId + "_IcnArrowBoxLabel").innerText = "こども人数の設定（現在" + childCount + "名）";
            //$get(elementId + "_IcnArrowDownLabel").innerText = "こども人数の設定（現在" + childCount + "名）";
            // 2011/05/10 1View対応 MOD M
            $get(elementId + "_IcnArrowBoxLabel").innerText = "こども人数";
            $get(elementId + "_IcnArrowDownLabel").innerText = "こども人数"
            // 2011/05/10 1View対応 MOD E
        }
    }
}

function SetRentACarDropDownList(elementId) {
    if ($get(elementId + "_RentalSubArea").selectedIndex == 0) {
        $get(elementId + "_RentalSubArea").selectedIndex = 1;
    }
    if ($get(elementId + "_RentalOffice").selectedIndex == 0) {
        $get(elementId + "_RentalOffice").selectedIndex = 1;
    }
    if ($get(elementId + "_ReturnSubArea").selectedIndex == 0) {
        $get(elementId + "_ReturnSubArea").selectedIndex = 1;
    }
    if ($get(elementId + "_ReturnOffice").selectedIndex == 0) {
        $get(elementId + "_ReturnOffice").selectedIndex = 1;
    }
}

// 人数変更 RPK-RC-J-0106対応
function ChangeCount(adultDropdown, childDropdown, roomCountDropDown, roomUserLabel) {

    // 大人人数
    var countAdult = 0;
    countAdult = $get(adultDropdown);
    // 子供人数
    var childElementId = childDropdown.slice(0, childDropdown.lastIndexOf("_"));
    var countChildA = 0;
    var countChildB = 0;
    var countChildC = 0;
    var countChildD = 0;
    var countBaby = 0;
    countChildA = $get(childElementId + "_CountChildA");
    countChildB = $get(childElementId + "_CountChildB");
    countChildC = $get(childElementId + "_CountChildC");
    countChildD = $get(childElementId + "_CountChildD");
    countBaby = $get(childElementId + "_CountBaby");

    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.UserCountChanged(
        countAdult.options[countAdult.selectedIndex].value,
        countChildA.options[countChildA.selectedIndex].value,
        countChildB.options[countChildB.selectedIndex].value,
        countChildC.options[countChildC.selectedIndex].value,
        countChildD.options[countChildD.selectedIndex].value,
        countBaby.options[countBaby.selectedIndex].value,
        GetUserCountDataOnSuccess,
        GetUserCountDataOnFailed,
        roomCountDropDown);
}

// 人数変更データ取得成功コールバック RPK-RC-J-0106対応
function GetUserCountDataOnSuccess(result, userContext, methodName) {
    var elementId = userContext.slice(0, userContext.lastIndexOf("_"));
    // 室数ドロップダウン
    if ((result.RoomCountList != null) && (result.RoomCountList.length > 0)) {
        SetDropDownData($get(elementId + "_RoomCount"), result.RoomCountList, 0);
    }
    // ブラウザ判定 部屋人数ラベル
    if ($get(elementId + "_RoomCapacityLabel").textContent) {
        $get(elementId + "_RoomCapacityLabel").textContent = result.RoomUserLabel;
    } else {
        $get(elementId + "_RoomCapacityLabel").innerText = result.RoomUserLabel;
    }
    var RoomCapacity = $get(elementId + "_RoomCapacity");
    RoomCapacity.selectedIndex = result.RoomUser - 1;

}

// 人数変更データ取得失敗コールバック RPK-RC-J-0106対応
function GetUserCountDataOnFailed(error, userContext, methodName) { }

// 部屋数変更 RPK-RC-J-0106対応
function ChangeRoomCount(adultDropdown, childDropdown, roomCountDropDown) {

    // 大人人数
    var countAdult = $get(adultDropdown);
    // 子供人数
    var childElementId = childDropdown.slice(0, childDropdown.lastIndexOf("_"));
    var countChildA = $get(childElementId + "_CountChildA");
    var countChildB = $get(childElementId + "_CountChildB");
    var countChildC = $get(childElementId + "_CountChildC");
    var countChildD = $get(childElementId + "_CountChildD");
    var countBaby = $get(childElementId + "_CountBaby");

    var countRoom = $get(childElementId + "_RoomCount");
    // Webサービスを呼び出す。
    JTB.RTP.Front.Web.UI.Search.UserControl.PFSPS011WebService.RoomCountChanged(
        countAdult.options[countAdult.selectedIndex].value,
        countChildA.options[countChildA.selectedIndex].value,
        countChildB.options[countChildB.selectedIndex].value,
        countChildC.options[countChildC.selectedIndex].value,
        countChildD.options[countChildD.selectedIndex].value,
        countBaby.options[countBaby.selectedIndex].value,
        countRoom.options[countRoom.selectedIndex].value,
        GetRoomCountDataOnSuccess,
        GetRoomCountDataOnFailed,
        roomCountDropDown);
}

// 部屋数変更データ取得成功コールバック RPK-RC-J-0106対応
function GetRoomCountDataOnSuccess(result, userContext, methodName) {
    var elementId = userContext.slice(0, userContext.lastIndexOf("_"));
    // ブラウザ判定 部屋人数ラベル
    if ($get(elementId + "_RoomCapacityLabel").textContent) {
        $get(elementId + "_RoomCapacityLabel").textContent = result.RoomUserLabel;
    } else {
        $get(elementId + "_RoomCapacityLabel").innerText = result.RoomUserLabel;
    }
    var RoomCapacity = $get(elementId + "_RoomCapacity");
    RoomCapacity.selectedIndex = result.RoomUser - 1;

}

// 部屋数変更データ取得失敗コールバック RPK-RC-J-0106対応
function GetRoomCountDataOnFailed(error, userContext, methodName) { }

