/*
 * @include "IFrameLoading.js"
 * @include "DDP_Framework.js"
 * @include "DDP_Signin.js"
 * @include "DDP_Search.js"
 * @include "DDP.SearchConfig.js"
 */

/**
 * @fileOverview TOP画面の機能を保有するファイルです。
 */

/**
 * DDP.Search.TopSearchPanel コンストラクタの定義
 * @class トップ画面の検索条件パネルを操作する為のクラスです。
 * @constructor
 */
DDP.Search.TopSearchPanel = function () {
	var getN = DDP.getNode, idMgr = DDP.Search.idManager;
	// 検索条件
	this.searchKbn1 = getN(idMgr["searchKbn1"]);
	this.searchKbn2 = getN(idMgr["searchKbn2"]);
	this.searchKbn3 = getN(idMgr["searchKbn3"]);
	this.capacity = getN(idMgr["capacity"]);
	this.dateGo = getN(idMgr["date_go"]);
	this.timeGo = getN(idMgr["time_go"]);
	this.dateBack = getN(idMgr["date_back"]);
	this.timeBack = getN(idMgr["time_back"]);
	// 航空検索条件
	this.airHeader = getN("h2-air-h");
	this.airContent = getN("h2-air-table");
	this.airportGoDeparture = getN(idMgr["airport_go_departure"]);
	this.airportGoDepatureCookie = getN(idMgr["airport_go_depature_cookie"]);
	this.airportGoArrive = getN(idMgr["airport_go_arrive"]);
	this.seatGo = getN(idMgr["seat_go"]);
	this.airportChange = getN("airport_change");
	this.backLinkDisplayFlag = getN(idMgr["back_link_display_flag"]);
	this.backTr2 = getN("back_tr2");
	this.backTr3 = getN("back_tr3");
	this.backTr4 = getN("back_tr4");
	this.airportBackDeparture = getN(idMgr["airport_back_departure"]);
	this.airportBackArrive = getN(idMgr["airport_back_arrive"]);
	this.seatBack = getN(idMgr["seat_back"]);
	this.airline = getN(idMgr["airline"]);
	// 宿泊検索条件
	this.hotelHeader = getN("h2-stay-h");
	this.hotelContent = getN("h2-stay-table");
	this.stayTofuken = getN(idMgr["stay_tofuken"]);
	this.stayTofukenTempValue = getN(idMgr["stay_tofuken_temp_value"]);
	this.stayArea = getN(idMgr["stay_area"]);
	this.stayAreaTempValue = getN(idMgr["stay_area_temp_value"]);
	this.roomMax = getN(idMgr["room_max"]);
	this.roomChargeTr = getN("room_charge_tr");
	this.chargeMin = getN(idMgr["charge_min"]);
	this.chargeMax = getN(idMgr["charge_max"]);
	this.roomMealType = getN("room_meal_type");
	this.roomMealDisplayFlag = getN(idMgr["room_meal_display_flag"]);
	this.roomMealTr2 = getN("room_meal_tr2");
	this.roomMealTr3 = getN("room_meal_tr3");
	this.roomType = getN(idMgr["room_type"]);
	this.mealType = getN(idMgr["meal_type"]);
	// レンタカー検索条件
	this.carHeader = getN("h2-car-h");
	this.carContent = getN("h2-car-table");
	this.carConditionTr = getN("carConditionTr");
	this.carConditionLink = getN("carConditionLink");
	this.carConditionDisplayStartEndFlag = getN(idMgr["carConditionDisplay_StartEnd_Flag"]);
	this.carConditionStartTr = getN("carConditionStartTr");
	this.rentalStartArea = getN(idMgr["rentalStartArea"]);
	this.rentalStartSubArea = getN(idMgr["rentalStartSubArea"]);
	this.rentalStartOffice = getN(idMgr["rentalStartOffice"]);
	this.rentalStartDateTr = getN("rentalStartDateTr");
	this.rentalStartDate = getN(idMgr["rentalStartDate"]);
	this.carEndConditionTr = getN("carEndConditionTr");
	this.carConditionEndLink = getN("carConditionEndLink");
	this.carConditionDisplayEndFlag = getN(idMgr["carConditionDisplay_End_Flag"]);
	this.carConditionEndTr = getN("carConditionEndTr");
	this.rentalEndArea = getN(idMgr["rentalEndArea"]);
	this.rentalEndSubArea = getN(idMgr["rentalEndSubArea"]);
	this.rentalEndOffice = getN(idMgr["rentalEndOffice"]);
	this.rentalEndDateTr = getN("rentalEndDateTr");
	this.rentalEndDate = getN(idMgr["rentalEndDate"]);
	this.carCnt = getN(idMgr["carCntList"]);
	this.carClass = getN(idMgr["carClassList"]);
	this.smoke = getN(idMgr["smokeList"]);
	this.carDetailLink = getN("carDetailLink");
	this.carDetailDisplayFlag = getN(idMgr["carDetailDisplayFlag"]);
	this.carClassTr = getN("tr_car_class");
	this.carSmokeTr = getN("tr_smoke");
	this.AtMtTr = getN("tr_AtMt");
	this.transmission = getN(idMgr["transmissionList"]);
	this.TransmissionTr = getN("tr_transmission");
	this.drivekbn = getN(idMgr["drivekbnList"]);
	// ボタン・リンク
	this.reference = getN(idMgr["reference"]);
	// Hidden
	this.mapSearchType = getN(idMgr["map_search_type"]);
	this.defaultValuesManager = null;
	return this;
};

/**
 * DDP.Search.TopSearchPanel 初期化処理をおこないます。
 */
DDP.Search.TopSearchPanel.prototype.init = function () {
	var __this = this , _addE = DDP.addEvent,
		_sa = DDP.Search.saveArea, _setABTV = DDP.Search.setAreaByTempValue, _syncPDSV = DDP.syncPullDownSelectedValue,
		_chKABAC = DDP.Search.changeKenAreaByAirportCode, _chSABKA = DDP.Search.changeSubAreaByKenArea;
	// DDP.Search.Mapのインスタンス作成
	this.supportMap = new DDP.Search.Map("img_maps", this.stayTofuken.id, this.stayArea.id, "map_select_link");
	//conditionの設定
	this.syncCondition = this.createSyncCondition();
	// 同期オブジェクト
	var syncMgr = this.syncManager = new DDP.Search.SyncManager(this.syncCondition);
	// 既定値制御
	this.defaultValuesManager = this.createDefaultValuesManager();
	var rsvKbn = DDP.Search.SyncManager.prototype.getRsvKbn(
		this.syncCondition.searchKbn1, this.syncCondition.searchKbn2, this.syncCondition.searchKbn3);
	// テーブル・リンク情報を制御
	var isMapRedirect = this.initDisplays(rsvKbn);
	
	// データの初期化処理
	this.supportMap.init();
	// 空港が所属する県によって宿泊地域を変更
	_chKABAC(this.airportGoArrive, this.stayTofuken, this.supportMap);
	// 宿泊地域を保存してある値に変更
	_setABTV(this.stayTofuken,this.stayTofukenTempValue);
	// 宿泊地区を保存してある値に変更
	_setABTV(this.stayArea,this.stayAreaTempValue);
	// 宿泊地域によって宿泊地区を変更
	_chSABKA(this.stayTofuken, this.stayArea);
	//=====================================================================
	// レンタカー初期化処理
	//=====================================================================
	// レンタカー貸出地域とレンタカー貸出地区を同期
	_chSABKA(this.rentalStartArea, this.rentalStartSubArea);
	// レンタカー返却地域とレンタカー返却地区を同期
	_chSABKA(this.rentalEndArea, this.rentalEndSubArea);
	// レンタカー貸出地区とレンタカー貸出店舗の同期
	syncMgr.syncRentalStartOfficeByRentalStartSubtArea();
	// レンタカー返却地区とレンタカー返却店舗の同期
	syncMgr.syncRentalEndOfficeByRentalEndSubtArea();
	// 既定値の設定
	if (!isMapRedirect) {
		this.defaultValuesManager.setDefault(rsvKbn);
	}
	// 出発日・帰着日からレンタカー貸出・返却年月日を設定
	this.updateRentalDate();
	// 地図描画
	this.supportMap.write();

	// イベント登録
	var prm = Sys.WebForms.PageRequestManager.getInstance();
	prm.add_beginRequest(function(sender, args) { __this.onBeginRequest(sender, args); });
	prm.add_endRequest(function(sender, args) { __this.onEndRequest(sender, args); });
	// ◆検索条件◆
	// 航空+宿泊+レンタカー
	_addE(this.searchKbn1, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.SearchAirHotelCar); });
	// 航空+宿泊
	_addE(this.searchKbn2, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.SearchAirHotel); });
	// 宿泊+レンタカー
	_addE(this.searchKbn3, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.SearchHotelCar); });
	// 人数
	_addE(this.capacity, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.Capacity); });
	// 出発日
	_addE(__this.dateGo, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.DateGo); });
	// 帰着日
	_addE(__this.dateBack, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.DateBack); });
	// ◆航空条件◆
	// 往路出発空港
	_addE(this.airportGoDeparture, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.AirGoDep); });
	// 往路到着空港
	_addE(this.airportGoArrive, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.AirGoArr); });
	// 往路搭乗クラス
	_addE(this.seatGo, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.AirGoSeat); });
	// 復路出発空港
	_addE(this.airportBackDeparture, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.AirBackDep); });
	// 復路リンク
	_addE(this.airportChange, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.AirBackLink); });
	// ◆宿泊条件◆
	// 県プルダウン
	_addE(this.stayTofuken, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.Prefecture); });
	// 地区プルダウン
	_addE(this.stayArea, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.SubArea); });
	// 部屋食事リンク
	_addE(this.roomMealType, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.RoomMealLink); });
	// ◆レンタカー条件◆
	// レンタカー車両詳細情報
	_addE(this.carDetailLink, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarDetailLink); });
	// レンタカー返却店舗
	_addE(this.carConditionEndLink, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarConditionEndLink); });
	// レンタカー貸出・返却店舗
	_addE(this.carConditionLink, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarConditionLink); });
	// レンタカー貸出地域
	_addE(this.rentalStartArea, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarStartArea); });
	// レンタカー貸出地区
	_addE(this.rentalStartSubArea, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarStartSubArea); });
	// レンタカー貸出店舗
	_addE(this.rentalStartOffice, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarStartOffice); });
	// レンタカー返却地域
	_addE(this.rentalEndArea, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarEndArea); });
	// レンタカー返却地区
	_addE(this.rentalEndSubArea, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.CarEndSubArea); });
	// ◆ボタン◆
	_addE(this.reference, "click", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.SearchButton); });
};
/**
 * リクエスト開始時のイベント
 * @param sender イベント発生元
 * @param args イベント引数
 */
DDP.Search.TopSearchPanel.prototype.onBeginRequest = function(sender, args) {
	this.asyncPostBackId = args.get_postBackElement().id;
	this.prevValueDateGo = DDP.Search.PullDown.selectedValue(this.dateGo);
	this.prevValueDateBack = DDP.Search.PullDown.selectedValue(this.dateBack);
};
/**
 * リクエスト終了時のイベント
 * @param sender イベント発生元
 * @param args イベント引数
 */
DDP.Search.TopSearchPanel.prototype.onEndRequest = function(sender, args) {
	// UpdatePanel更新後の再設定
	var __this = this, getN = DDP.getNode, idMgr = DDP.Search.idManager;
	this.dateGo = getN(idMgr["date_go"]);
	this.dateBack = getN(idMgr["date_back"]);
	this.defaultValuesManager = this.createDefaultValuesManager();
	if (0 <= this.asyncPostBackId.indexOf(idMgr["SupportCalendarGo"]) &&
		this.prevValueDateGo != DDP.Search.PullDown.selectedValue(this.dateGo)) {
		DDP.addEvent(__this.dateGo, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.DateGo); });
		this.cascade(DDP.Search.TopSearchPanel.CascadeType.DateGo);
	} else if (0 <= this.asyncPostBackId.indexOf(idMgr["SupportCalendarBack"]) &&
		this.prevValueDateBack != DDP.Search.PullDown.selectedValue(this.dateBack)) {
		DDP.addEvent(__this.dateBack, "change", function() { __this.cascade(DDP.Search.TopSearchPanel.CascadeType.DateBack); });
		this.cascade(DDP.Search.TopSearchPanel.CascadeType.DateBack);
	}
};
/**
 * 既定値操作オブジェクトを作成します。
 */
DDP.Search.TopSearchPanel.prototype.createDefaultValuesManager = function() {
	var common = new DDP.Search.DefaultValuesElements.Common(
		"capacity", "date_go", "time_go", "date_back", "time_back");
	var air = new DDP.Search.DefaultValuesElements.Air(
		"airport_go_departure", "airport_go_arrive", "seat_go", null,
		"airport_back_departure", "airport_back_arrive", "seat_back", null,
		"airline");
	var hotel = new DDP.Search.DefaultValuesElements.Hotel(
		"room_max", "charge_min", "charge_max", "room_type", "meal_type",
		"stay_tofuken", "stay_area", null);
	var car = new DDP.Search.DefaultValuesElements.Car(
		"carCntList", "carClassList", "smokeList", "transmissionList", "drivekbnList",
		"rentalStartArea", "rentalStartSubArea", "rentalStartOffice",
		"rentalEndArea", "rentalEndSubArea", "rentalEndOffice",
		null);
	var elms = new DDP.Search.DefaultValuesElements(common, air, hotel, car);
	return new DDP.Search.DefaultValuesManager(
		DDP.Search.DefaultValuesManager.Mode.Top, elms, this.syncManager);
};
/**
 * 検索パネルの値の初期化時に使用する初期値として現在の値を保存します。
 */
DDP.Search.TopSearchPanel.prototype.saveInitialValue = function() {
	this.initalValues = {
		selectedIndex: {
			timeGo: this.timeGo.selectedIndex,
			timeBack: this.timeBack.selectedIndex,
			airportGoDeparture: this.airportGoDeparture.selectedIndex,
			airportGoArrive: this.airportGoArrive.selectedIndex,
			airportBackDeparture: this.airportBackDeparture.selectedIndex,
			airportBackArrive: this.airportBackArrive.selectedIndex,
			airline: this.airline.selectedIndex,
			seatGo: this.seatGo.selectedIndex,
			seatBack: this.seatBack.selectedIndex,
			roomMax: this.roomMax.selectedIndex,
			chargeMin: this.chargeMin.selectedIndex,
			chargeMax: this.chargeMax.selectedIndex,
			roomType: this.roomType.selectedIndex,
			mealType: this.mealType.selectedIndex,
			stayTofuken: this.stayTofuken.selectedIndex,
			stayArea: this.stayArea.selectedIndex,
			capacity: this.capacity.selectedIndex,
			dateGo: this.dateGo.selectedIndex,
			dateBack: this.dateBack.selectedIndex,
			carCnt:this.carCnt.selectedIndex,
			carClass:this.carClass.selectedIndex,
			smoke:this.smoke.selectedIndex,
			transmission:this.transmission.selectedIndex,
			drivekbn:this.drivekbn.selectedIndex,
			rentalStartArea:this.rentalStartArea.selectedIndex,
			rentalStartSubArea:this.rentalStartSubArea.selectedIndex,
			rentalStartOffice:this.rentalStartOffice.selectedIndex,
			rentalEndArea:this.rentalEndArea.selectedIndex,
			rentalEndSubArea:this.rentalEndSubArea.selectedIndex,
			rentalEndOffice:this.rentalEndOffice.selectedIndex
		},
		value: {
			backLinkDisplayFlag: this.backLinkDisplayFlag.value,
			roomMealDisplayFlag: this.roomMealDisplayFlag.value,
			airportGoDepatureCookie: this.airportGoDepatureCookie.value
		},
		checkd: {
			searchKbn1:this.searchKbn1.checked,
			searchKbn2:this.searchKbn2.checked,
			searchKbn3:this.searchKbn3.checked
		}
	}
};
/**
 * 検索パネルの値を初期値に解除します。
 */
DDP.Search.TopSearchPanel.prototype.cancellationSearchCondition = function() {
	for(var valueType in this.initalValues) {
		var values = this.initalValues[valueType];
		for(var controlId in values) {
			this[controlId][valueType] = values[controlId];
		}
	}
	//レンタカー返却店舗条件
	this.syncManager.syncRentalStartSubAreaByRentalStartArea();
	this.rentalStartSubArea.selectedIndex = this.initalValues.selectedIndex.rentalStartSubArea;
	this.syncManager.syncRentalStartOfficeByRentalStartSubtArea();
	this.rentalStartOffice.selectedIndex = this.initalValues.selectedIndex.rentalStartOffice;
	//レンタカー返却店舗
	this.syncManager.syncRentalEndSubAreaByRentalEndArea();
	this.rentalEndSubArea.selectedIndex = this.initalValues.selectedIndex.rentalEndSubArea;
	this.syncManager.syncRentalEndOfficeByRentalEndSubtArea();
	this.rentalEndOffice.selectedIndex = this.initalValues.selectedIndex.rentalEndOffice;
};
/**
 * 予約区分によりテーブル・リンク情報を初期化します。
 * @param rsvKbn 予約区分
 */
DDP.Search.TopSearchPanel.prototype.initDisplays = function(rsvKbn) {
	var DSC = DDP.Search.Const;
	// 各商材テーブルの表示を切り替え
	this.switchTables(rsvKbn);
	// 基本検索条件の表示設定
	this.changeBasicView(rsvKbn);
	// リンクを制御
	this.switchReturnTrip(true);
	this.switchRoomTypesMealType(true);
	this.changeRentaCarLink(rsvKbn);
	if (rsvKbn == DSC.RSV_KBN_AIR_HOTEL_CAR) {
		this.switchRentalView(true);
	} else if (rsvKbn == DSC.RSV_KBN_HOTEL_CAR) {
		this.switchRentalEndView(true);
	} else {
		this.switchCarDetail(true);
	}
	// 地図からの遷移の場合
	var mapSearchTypeValue = this.mapSearchType.value;
	var isMapRedirect = (
		mapSearchTypeValue == DDP.Search.MapSearchType.CarRentalStart ||
		mapSearchTypeValue == DDP.Search.MapSearchType.CarRentalEnd);
	if (isMapRedirect) {
		this.mapSearchType.value = "";
		if (rsvKbn == DSC.RSV_KBN_AIR_HOTEL_CAR) {
			this.switchRentalView();
		} else if(rsvKbn == DSC.RSV_KBN_HOTEL_CAR) {
			this.switchRentalEndView();
		}
	}
	return isMapRedirect;
};
/*
 * 入力連動種別
 */
DDP.Search.TopSearchPanel.CascadeType = {
	Capacity : 0,
	DateGo : 1,
	DateBack : 2,
	AirGoDep : 4,
	AirGoArr : 8,
	AirGoSeat : 16,
	AirBackDep : 32,
	AirBackLink : 64,
	Prefecture : 128,
	SubArea : 256,
	RoomMealLink : 512,
	CarDetailLink : 1024,
	CarConditionEndLink : 2048,
	CarConditionLink : 4096,
	CarStartArea : 8192,
	CarStartSubArea : 16384,
	CarStartOffice : 32768,
	CarEndArea : 65536,
	CarEndSubArea : 131072,
	SearchButton : 262144,
	SearchAirHotel : 524288,
	SearchAirHotelCar : 1048576,
	SearchHotelCar : 2097152
};
/**
 * 入力コントロールの連動処理を行います。
 * @param type DDP.Search.TopSearchPanel.CascadeTypeのいずれかの値。
 */
DDP.Search.TopSearchPanel.prototype.cascade = function(type) {
	var __this = this, syncMgr = __this.syncManager, onlyOpenClose = true,
		CascadeType = DDP.Search.TopSearchPanel.CascadeType,
		_sa = DDP.Search.saveArea, _syncPDSV = DDP.syncPullDownSelectedValue,
		_chKABAC = DDP.Search.changeKenAreaByAirportCode, _chSABKA = DDP.Search.changeSubAreaByKenArea;
	// リンクなどの開閉
	switch(type) {
		// 行き/帰りの区間が異なる場合リンク
		case CascadeType.AirBackLink: __this.switchReturnTrip(); break;
		// 部屋食事リンク
		case CascadeType.RoomMealLink: __this.switchRoomTypesMealType(); break;
		// 車両仕様リンク
		case CascadeType.CarDetailLink: __this.switchCarDetail(); break;
		// 貸出店舗以外に返却するリンク
		case CascadeType.CarConditionEndLink: __this.switchRentalEndView(); break;
		// 貸出店舗と返却店舗を指定するリンク
		case CascadeType.CarConditionLink: __this.switchRentalView(); break;
		// 検索区分 航空+宿泊
		case CascadeType.SearchAirHotel: __this.onChangeSearchKbn(DDP.Search.Const.RSV_KBN_AIR_HOTEL); break;
		// 検索区分 航空+宿泊+レンタカー
		case CascadeType.SearchAirHotelCar: __this.onChangeSearchKbn(DDP.Search.Const.RSV_KBN_AIR_HOTEL_CAR); break;
		// 検索区分 宿泊+レンタカー
		case CascadeType.SearchHotelCar: __this.onChangeSearchKbn(DDP.Search.Const.RSV_KBN_HOTEL_CAR); break;
		default: onlyOpenClose = false;
	}
	if (onlyOpenClose) { return; }
	
	// 人数
	if (type == CascadeType.Capacity) {
		if (!__this.roomMax.disabled) {
			// 部屋定員と同期
			_syncPDSV(__this.capacity,__this.roomMax);
		}
		return;
	}
	// 出発日・帰着日
	if (CascadeType.DateGo <= type && type <= CascadeType.DateBack) {
		if (type == CascadeType.DateGo) {
			// 帰着日を出発日+nに変更
			DDP.Search.changeDateGo(__this.dateGo, __this.dateBack); 
		}
		// 出発日・帰着日からレンタカー貸出・返却年月日を設定
		__this.updateRentalDate();
		return;
	}

	// 往路出発空港
	if (type == CascadeType.AirGoDep) {
		// 往路出発空港と復路到着空港の同期
		_syncPDSV(__this.airportGoDeparture, __this.airportBackArrive);
		return;
	}
	// 往路搭乗クラス
	if (type == CascadeType.AirGoSeat) {
		// 往路搭乗クラスと復路搭乗クラスを同期
		_syncPDSV(__this.seatGo, __this.seatBack);
		return;
	}
	// 往路到着空港
	if (type == CascadeType.AirGoArr) {
		// 空港が所属する県によって宿泊地域を変更
		_chKABAC(__this.airportGoArrive, __this.stayTofuken, __this.supportMap);
		// 宿泊地域によって宿泊地区を変更
		_chSABKA(__this.stayTofuken, __this.stayArea);
		// 往路到着空港と復路出発空港の同期
		_syncPDSV(__this.airportGoArrive, __this.airportBackDeparture);
		// 往路到着空港とレンタカー貸出店舗の同期
		syncMgr.syncRentalStartOfficeByGoArriveAirport();
	}
	// 復路出発空港
	if (type <= CascadeType.AirBackDep) {
		// 復路出発空港とレンタカー返却店舗の同期
		syncMgr.syncRentalEndOfficeByGoArriveAirport();
		return;
	}
	// 宿泊地域
	if (type == CascadeType.Prefecture) {
		// 宿泊地域によって宿泊地区を変更
		_chSABKA(__this.stayTofuken, __this.stayArea);
		// 宿泊地域とレンタカー貸出条件の同期
		syncMgr.syncRentalStartAreaConditionByKenArea();
		// 宿泊地域とレンタカー返却条件の同期
		syncMgr.syncRentalEndAreaConditionByKenArea();
		return;
	}
	// 宿泊地区
	if (type == CascadeType.SubArea) {
		// 宿泊地区とレンタカー貸出条件の同期
		syncMgr.syncRentalStartCarConditionBySubArea();
		// 宿泊地区とレンタカー返却条件の同期
		syncMgr.syncRentalEndCarConditionBySubArea();
		return;
	}
	// レンタカー貸出地域
	if (type == CascadeType.CarStartArea) {
		// レンタカー貸出地域とレンタカー貸出地区の同期
		syncMgr.syncRentalStartSubAreaByRentalStartArea();
		// レンタカー貸出地区とレンタカー貸出店舗の同期
		syncMgr.syncRentalStartOfficeByRentalStartSubtArea();
		// レンタカー貸出条件とレンタカー返却条件の同期
		syncMgr.syncRentalEndAreaByRentalStartArea();
		return;
	}
	// レンタカー貸出地区
	if (type == CascadeType.CarStartSubArea) {
		// レンタカー貸出地区とレンタカー貸出店舗の同期
		syncMgr.syncRentalStartOfficeByRentalStartSubtArea();
		// レンタカー貸出地区とレンタカー返却地区の同期
		syncMgr.syncRentalEndSubAreaByRentalStartArea();
		return;
	}
	// レンタカー貸出店舗
	if (type == CascadeType.CarStartOffice) {
		// レンタカー貸出店舗とレンタカー返却店舗の同期
		syncMgr.syncRentalEndOfficeByRentalStartOffice();
		return;
	}
	// レンタカー返却地域
	if (type == CascadeType.CarEndArea) {
		// レンタカー返却地域とレンタカー返却地区の同期
		syncMgr.syncRentalEndSubAreaByRentalEndArea();
	}
	// レンタカー返却地区
	if (type <= CascadeType.CarEndSubArea) {
		// レンタカー返却地区とレンタカー返却店舗の同期
		syncMgr.syncRentalEndOfficeByRentalEndSubtArea();
		return;
	}
	// 検索ボタン
	if (type == CascadeType.SearchButton) {
		// 宿泊地域の値を一時保存
		_sa(__this.stayArea,__this.stayAreaTempValue);
		// 宿泊地区の値を一時保存
		_sa(__this.stayTofuken,__this.stayTofukenTempValue);
		return;
	}
};
/**
 * 検索区分変更時の処理を行います。
 * @param rsvKbn 予約区分
 */
DDP.Search.TopSearchPanel.prototype.onChangeSearchKbn = function(rsvKbn) {
	var __this = this, DSC = DDP.Search.Const;
	// 各商材テーブルの表示を切り替え
	__this.switchTables(rsvKbn);
	// 基本検索条件の表示設定
	__this.changeBasicView(rsvKbn);
	if (rsvKbn == DSC.RSV_KBN_AIR_HOTEL_CAR || rsvKbn == DSC.RSV_KBN_HOTEL_CAR) {
		__this.changeRentaCarLink(rsvKbn);
		// 「貸出店舗と返却店舗を指定する場合 」リンクの表示フラグを初期化
		__this.carConditionDisplayStartEndFlag.value = DSC.FLAG_FALSE;
		__this.carConditionDisplayEndFlag.value = DSC.FLAG_FALSE;
	}
	// 既定値設定
	__this.defaultValuesManager.setDefault(rsvKbn);
	// 出発日・帰着日からレンタカー貸出・返却年月日を設定
	__this.updateRentalDate();
	// 地図描画
	__this.supportMap.write();
};
/**
 * 商材領域の表示の切り替えを行います
 * @param rsvKbn 予約区分
 */
DDP.Search.TopSearchPanel.prototype.switchTables = function(rsvKbn) {
	var __this = this, DSC = DDP.Search.Const;
	if (rsvKbn != DSC.RSV_KBN_AIR_HOTEL &&
		rsvKbn != DSC.RSV_KBN_AIR_HOTEL_CAR &&
		rsvKbn != DSC.RSV_KBN_HOTEL_CAR) {
		return;
	}
	DDP.setVisible(__this.airHeader, rsvKbn != DSC.RSV_KBN_HOTEL_CAR);
	DDP.setVisible(__this.airContent, rsvKbn != DSC.RSV_KBN_HOTEL_CAR);
	DDP.setVisible(__this.hotelHeader, true);
	DDP.setVisible(__this.hotelContent, true);
	DDP.setVisible(__this.carHeader, rsvKbn != DSC.RSV_KBN_AIR_HOTEL);
	DDP.setVisible(__this.carContent, rsvKbn != DSC.RSV_KBN_AIR_HOTEL);
};
/**
 * 検索条件の表示を切り替えます。
 */
DDP.Search.TopSearchPanel.prototype.changeBasicView = function(rsvKbn) {
	//var __this = this;
	//var display = !(rsvKbn == DDP.Search.Const.RSV_KBN_HOTEL_CAR);
	//DDP.setVisible(__this.timeGo, display);
	//DDP.setVisible(__this.timeBack, display);
};
/**
 * 復路検索条件の表示・非表示を切り替えます。
 * @param init 初期化の場合は true 、以外は false 。
 */
DDP.Search.TopSearchPanel.prototype.switchReturnTrip = function(init) {
	var __this = this, isInit = !!init;
	var display = !__this.getNowDisplay(__this.backLinkDisplayFlag.value);
	if (!isInit) {
		__this.backLinkDisplayFlag.value = __this.getDisplayString(display);
	} else {
		display = !display;
	}
	DDP.setVisible(__this.backTr2, display);
	DDP.setVisible(__this.backTr3, display);
	DDP.setVisible(__this.backTr4, display);
	__this.changeSwitchingLinkClass(__this.airportChange, display);
};
/**
 * 部屋食事検索条件表示・非表示を切り替えます。
 * @param init 初期化の場合は true 、以外は false 。
 */
DDP.Search.TopSearchPanel.prototype.switchRoomTypesMealType = function(init) {
	var __this = this, isInit = !!init;
	var display = !__this.getNowDisplay(__this.roomMealDisplayFlag.value);
	if (!isInit) {
		__this.roomMealDisplayFlag.value = __this.getDisplayString(display);
	} else {
		display = !display;
	}
	DDP.setVisible(__this.roomChargeTr, display);
	DDP.setVisible(__this.roomMealTr2, display);
	DDP.setVisible(__this.roomMealTr3, display);
	__this.changeSwitchingLinkClass(__this.roomMealType, display);
};
/**
 * 店舗リンクを切り替えます
 * @param rsvKbn 予約区分
 */
DDP.Search.TopSearchPanel.prototype.changeRentaCarLink = function(rsvKbn) {
	var __this = this, DSC = DDP.Search.Const;
	if (rsvKbn != DSC.RSV_KBN_AIR_HOTEL_CAR &&
		rsvKbn != DSC.RSV_KBN_AIR_HOTEL &&
		rsvKbn != DSC.RSV_KBN_HOTEL_CAR) {
		return;
	}
	DDP.setVisible(__this.carConditionTr, rsvKbn == DSC.RSV_KBN_AIR_HOTEL_CAR);
	DDP.setVisible(__this.carConditionStartTr, rsvKbn == DSC.RSV_KBN_HOTEL_CAR);
	DDP.setVisible(__this.carConditionEndTr, false);
	DDP.setVisible(__this.carEndConditionTr, rsvKbn == DSC.RSV_KBN_HOTEL_CAR);
};
/**
 * レンタカー店舗の切り替えを行います
 * @param init 初期化の場合は true 、以外は false 。
 */
DDP.Search.TopSearchPanel.prototype.switchRentalView = function(init) {
	var __this = this, isInit = !!init;
	var flag = __this.carConditionDisplayStartEndFlag;
	var display = __this.getNowDisplay(flag.value);
	if (!isInit) {
		display = !display;
		flag.value = __this.getDisplayString(display);
	}
	DDP.setVisible(__this.carConditionStartTr, display);
	DDP.setVisible(__this.carConditionEndTr, display);
	__this.changeSwitchingLinkClass(__this.carConditionLink, display);
};
/**
 * レンタカー返却店舗の切り替えを行います
 * @param init 初期化の場合は true 、以外は false 。
 */
DDP.Search.TopSearchPanel.prototype.switchRentalEndView = function(init) {
	var __this = this, isInit = !!init;
	var flag = __this.carConditionDisplayEndFlag;
	var display = __this.getNowDisplay(flag.value);
	if (!isInit) {
		display = !display;
		flag.value = __this.getDisplayString(display);
	}
	DDP.setVisible(__this.carConditionEndTr, display);
	__this.changeSwitchingLinkClass(__this.carConditionEndLink, display);
};
/**
 * レンタカー検索条件表示・非表示を切り替えます。
 * @param init 初期化の場合は true 、以外は false 。
 */
DDP.Search.TopSearchPanel.prototype.switchCarDetail = function(init) {
	var __this = this, isInit = !!init;
	var flag = __this.carDetailDisplayFlag;
	var display = __this.getNowDisplay(flag.value);
	if (!isInit) {
		display = !display;
		flag.value = __this.getDisplayString(display);
	}
	DDP.setVisible(__this.carClassTr, display);
	DDP.setVisible(__this.carSmokeTr, display);
	DDP.setVisible(__this.AtMtTr, display);
	DDP.setVisible(__this.TransmissionTr, display);
	__this.changeSwitchingLinkClass(__this.carDetailLink, display);
};
/**
 * 表示状態値から現在の表示状態を取得します。
 * @param value 表示状態値
 */
DDP.Search.TopSearchPanel.prototype.getNowDisplay = function(value) {
	return (value == DDP.Search.Const.FLAG_TRUE) ? true : false;
};
/*
 * 表示状態から表示状態値を取得します。
 * @param display 表示状態を表すboolean値
 */
DDP.Search.TopSearchPanel.prototype.getDisplayString = function(display) {
	return display ? DDP.Search.Const.FLAG_TRUE : DDP.Search.Const.FLAG_FALSE;
};
/**
 * 状態に応じて開閉リンクのStyleClassを変更します。
 * @param node 開閉リンク
 * @param isOpen 変更する開閉リンクの状態(true:開いた状態,false:閉じた状態。)
 */
DDP.Search.TopSearchPanel.prototype.changeSwitchingLinkClass = function(node, isOpen) {
	if (!node) return;
	DDP.removeClass(node, isOpen ? "ico-link3" : "ico-link4");
	DDP.addClass(node, isOpen ? "ico-link4" : "ico-link3");
};
/**
 * 同期コントロールを作成します。
 */
DDP.Search.TopSearchPanel.prototype.createSyncCondition = function() {
	var __this = this, c = new DDP.Search.SyncCondition();
	c.rentalStartArea = __this.rentalStartArea.id;
	c.rentalStartSubArea = __this.rentalStartSubArea.id;
	c.rentalStartOffice = __this.rentalStartOffice.id;
	c.rentalEndArea = __this.rentalEndArea.id;
	c.rentalEndSubArea = __this.rentalEndSubArea.id;
	c.rentalEndOffice = __this.rentalEndOffice.id;
	c.airportGoDeparture = __this.airportGoDeparture.id;
	c.airportGoArrive = __this.airportGoArrive.id;
	c.airportBackDeparture = __this.airportBackDeparture.id;
	c.airportBackArrive = __this.airportBackArrive.id;
	c.hotelArea = __this.stayTofuken.id;
	c.hotelSubArea = __this.stayArea.id;
	c.searchKbn1 = __this.searchKbn1.id;
	c.searchKbn2 = __this.searchKbn2.id;
	c.searchKbn3 = __this.searchKbn3.id;
	return c;
};
/**
 * レンタカー貸出返却年月日を更新します。
 */
DDP.Search.TopSearchPanel.prototype.updateRentalDate = function() {
	var c = this.syncCondition, _sv = DDP.setVisible;
	var rsvKbn = DDP.Search.SyncManager.prototype.getRsvKbn(
		c.searchKbn1, c.searchKbn2, c.searchKbn3);
	var updating = (
		rsvKbn == DDP.Search.Const.RSV_KBN_HOTEL_CAR ||
		rsvKbn == DDP.Search.Const.RSV_KBN_AIR_HOTEL_CAR);
	if (updating) {
		var fromToPullDowns = new DDP.Search.FromToPullDowns(
			this.dateGo, this.dateBack, this.rentalStartDate, this.rentalEndDate);
		fromToPullDowns.update();
	}
	_sv(this.rentalStartDateTr, updating);
	_sv(this.rentalEndDateTr, updating);
}
// 登録
DDP.addEvent(window, "load", function() {
	DDP.merge(DDP.Search.idManager, getTopIdList());
	var search1 = new DDP.Search.TopSearchPanel();
	search1.init();
});

