var isPageLoaded = false;
	function hotel_init(){ 
		change_checkout();
		hotelshowRoomPanel($('room_num'));
		if ($('e01-001-001').checked){
			openPanelCondition('js-panel-condition-001',$('js-panel-condition-001'));
			hotelTextCheckLandmark('pickup_stay_city','pickup_landmark');
			$('pickup_landmark').value=pickup_landmark_id;
		}
		if ($('e01-002-002').checked){
			openPanelCondition('js-panel-condition-002',$('js-panel-condition-002'));
		} 
		

		if ($('search_type').value!=""){
			changeHotelView($('search_type').value);
		}else{
			$('search_type').value="empty_search";
		}
		
		initCalendar();
		
		
	}
	
	var conditionObjs = new Array('js-panel-condition-001','js-panel-condition-002');
	function openPanelCondition(pane,trg){
		var chkz = document.getElementById('js-panel-condition').getElementsByTagName("span");
		var len = chkz.length;
		for(var i = 0; i<len; i++){
			chkz[i].style.fontWeight='normal';
		}
		trg.parentNode.style.fontWeight='bold';
		var len = conditionObjs.length;
		for(var i = 0; i<len; i++){
			document.getElementById(conditionObjs[i]).style.display = "none";
		}
		document.getElementById(pane).style.display = "block";
	}
	function openPanelDefHtl(pId,trg){

	var pane = document.getElementById(pId);
	var icn = trg.parentNode;

	if (icn.className == 'opner-closed ml20 mt3'){
		preloadIcnz('/images/parts/icn-arrow-b-02.gif','/images/parts/icn-arrow-u-03.gif');
		pane.style.display = 'block';
		icn.className = 'opner-opend ml20 mt3';
		trg.style.fontWeight = 'bold';
	}else{
		pane.style.display = 'none';
		preloadIcnz('/images/parts/icn-arrow-b-02.gif','/images/parts/icn-arrow-u-03.gif');
		icn.className = 'opner-closed ml20 mt3';
		trg.style.fontWeight = 'normal';
	}

}
	
	function changeHotelView(ViewType){
  		if (ViewType=="hotel_search"){
  			$('js-panel-top-pic1').style.display = "none";
  			$('js-panel-top-pic2').style.display = "";
  			$('js-panel-top-pic3').style.display = "none";
  			$('js-panel-003').style.display = "";
  			$('check-panel').style.display = "none";
  			$('js-panel-detail').style.display = "";
  			$('sbmod001-panel').style.display = "";
  			$('sbmod002-panel').style.display = "none";
  			$('sbmod003-panel').style.display = "none";
  			if ($('FormName')!=null){
  				if ($('FormName').value=='DFR01HTL01V01_Form'){
  					$('line001-panel').style.display = "";
  					$('line002-panel').style.display = "none";
  				}
  			}
  			
  			
  		}else if (ViewType== "map_search" ){
  			$('js-panel-top-pic1').style.display = "none";
  			$('js-panel-top-pic2').style.display = "none";
  			$('js-panel-top-pic3').style.display = "";
  			$('js-panel-003').style.display = "none";
  			$('check-panel').style.display = "none";
  			$('js-panel-detail').style.display = "none";
  			$('sbmod001-panel').style.display = "none";
  			$('sbmod002-panel').style.display = "";
  			$('sbmod003-panel').style.display = "none";
  			if ($('FormName')!=null){
  				if ($('FormName').value=='DFR01HTL01V01_Form'){
  					$('line001-panel').style.display = "";
  					$('line002-panel').style.display = "none";
  				}
  			}
  		}else if (ViewType== "empty_search" ){
  			$('js-panel-top-pic1').style.display = "";
  			$('js-panel-top-pic2').style.display = "none";
  			$('js-panel-top-pic3').style.display = "none";
  			$('js-panel-003').style.display = "";
  			$('check-panel').style.display = "";
  			$('js-panel-detail').style.display = "";
  			$('sbmod001-panel').style.display = "none";
  			$('sbmod002-panel').style.display = "none";
  			$('sbmod003-panel').style.display = "";
  			if ($('FormName')!=null){
  				if ($('FormName').value=='DFR01HTL01V01_Form'){
  					$('line001-panel').style.display = "none";
  					$('line002-panel').style.display = "";
  				}
  			}
  		}
  		
  		$('search_type').value=ViewType;
  		
	}
	
	function hotelshowRoomPanel(thisobj){
		var selected_num=thisobj.value;
		if (selected_num==""){
			for (var i=1;i<=parseInt(total_room_num);i++){
			$('room_panel_'+i).style.display = "none";
			}
		}else{
			$('js-panel-rooms001').style.display = "";
			for (var i=1;i<=parseInt(selected_num);i++){
				$('room_panel_'+i).style.display = "";
			}
			for (var i=parseInt(thisobj.value)+1;i<=parseInt(total_room_num);i++){
				$('room_panel_'+i).style.display = "none";
			}
		}	
	}
	
	
	function change_checkout(){
		if ($('stay_num')!=null){
			var currDate = new Date($('departureYearMonth_hotel').value.substr(0,4),($('departureYearMonth_hotel').value.substr(4,2)-0-1),$('departureDay_hotel').value);
			var expires = currDate.getTime() + parseInt($('stay_num').value) * 24 * 60 * 60 * 1000;            
			var checkout_date=new Date(expires);
			// 2009/5/11   \u80e1\u7956\u5fb3   M0182 
			varcurrDateStr = checkout_date.getFullYear()+"\u5e74"+(checkout_date.getMonth() + 1)+"\u6708"+toWeekDayString(checkout_date);
			// 2009/5/11   \u80e1\u7956\u5fb3   M0182 
			document.getElementById('js-panel-date001').innerHTML=varcurrDateStr;
		}
	}
	
	function checkOutDateChange(id){
		var inDateYM;
		var inDateDD;
		if (id == '0') {
			inDateYM = $('in_date_ym').value;
			inDateDD = $('in_date_dd').value;
		}
		if (id == '1') {	
			inDateYM = $('in_date_ym_all').value;
			inDateDD = $('in_date_dd_all').value;
		}	
		if (id == '2') {
			inDateYM = $('in_date_ym_1').value;
			inDateDD = $('in_date_dd_1').value;
		}
		if ($('date_num').value != null){
			var out_date;
			var out_date_d;
			var tempYear = inDateYM.substr(0,4);	
			var tempMonth = inDateYM.substr(4);
			tempMonth = parseInt(tempMonth,10) -1;	
			var tempDay = inDateDD.substr(0);
			var _tempDate = new Date(tempYear, tempMonth, tempDay).DateAdd('d',$('date_num').value);	
			var endDate = nowDate.DateAdd('d',departure_AfterDay);
		
			if(_tempDate.getTime() > endDate.getTime()) {
				_tempDate = endDate;	
			}
			
			var _tempMonth = parseInt(_tempDate.getMonth(),10) + 1;		
			out_date = _tempDate.getFullYear() + "" + (_tempMonth< 10?"0"+_tempMonth:_tempMonth) ;
		
			out_date_d = parseInt(_tempDate.getDate(),10) ;
			out_date_d = (out_date_d< 10?"0"+out_date_d:out_date_d) ;
	
			if (isPageLoaded) {
				if (id == '0') {
					$('out_date_ym').value = out_date;			
					$('out_date_dd').value = out_date_d;
					changeDepartureDayOptions("out_date_ym","out_date_dd",out_date_d);
					
				}
				if (id == '1') {
					$('out_date_ym_all').value = out_date;
					$('out_date_dd_all').value = out_date_d;
					changeDepartureDayOptions("out_date_ym_all","out_date_dd_all",out_date_d);
				}
				if (id == '2') {
					$('out_date_ym_1').value = out_date;
					$('out_date_dd_1').value = out_date_d;
					changeDepartureDayOptions("out_date_ym_1","out_date_dd_1",out_date_d);
				}
			}
		}
	}
	
	function hotelLoadArea(area,defaultValue){	

		$(area).length = 1;
		
		if(hotelAreaList == null)
			return;
		for(var i = 0; i < hotelAreaList.length;i++){
			
			$(area).options.add(new Option(hotelAreaList[i].name.unEscapeHTML(),hotelAreaList[i].code));
		}
		if(defaultValue != null && defaultValue != "") {
			$(area).value = defaultValue;
		}
	}
	
	function hotelCheckArea(area,country,city,landmark,defaultValue){
		$(city).length = 1;
		$(country).length = 1;
		
		if ($(landmark)!=null){
			$(landmark).length = 1;
			$(landmark).value = "";
		}
		$(city).value = "";
		$(country).value = "";
		if($(area).value == ""){	
			return;
		}
		if(hotelAreaGroup[0] == null || hotelAreaGroup[0][$(area).value]== null)
			return;
		var arr = hotelAreaGroup[0][$(area).value];

		for(var i = 0; i < arr.length;i++){	
			$(country).options.add(new Option(arr[i].name.unEscapeHTML(),arr[i].code));
			
		}
		
		if(defaultValue != null && defaultValue != "") {
		
			$(country).value = defaultValue;
		}
	}
	
	function hotelCheckCountry(area,country,city,landmark,defaultValue){
	
		$(city).length = 1;
		$(city).value = "";
		
		if ($(landmark)!=null){
			$(landmark).length = 1;
			$(landmark).value = "";
		}
		

		if($(country).value == ""){
			
			return;
		}
		if(hotelCountryGroup[0] == null || hotelCountryGroup[0][$(country).value]== null)
			return;
		var arr = hotelCountryGroup[0][$(country).value];
		for(var i = 0; i < arr.length;i++){		
			$(city).options.add(new Option(arr[i].name.unEscapeHTML(),arr[i].code));	
		}
		if(defaultValue != null && defaultValue != "") {
			$(city).value = defaultValue;
		}
	}
	
	function hotelCheckCity(city,landmark,defaultValue){
		
		$(landmark).length = 1;
		$(landmark).value = "";

		if($(city).value == ""){
			
			return;
		}
		if(hotelCityGroup[0] == null || hotelCityGroup[0][$(city).value]== null)
			return;
		var arr = hotelCityGroup[0][$(city).value];
		
		for(var i = 0; i < arr.length;i++){	
			$(landmark).options.add(new Option(arr[i].name.unEscapeHTML(),arr[i].code));
		}
		
		if(defaultValue != null && defaultValue != "") {
			$(landmark).value = defaultValue;
		}
	}
	
	function hotelTextCheckLandmark(city,landmark,defaultValue){
		$(landmark).length = 1;
		$(landmark).value = "";
		// 2009/5/11   \u80e1\u7956\u5fb3   M0182 
		if($(city).value == "" || $(city).value.length<3 || $(city).value.length=="\u90fd\u5e02\u540d\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044"){
		// 2009/5/11   \u80e1\u7956\u5fb3   M0182 	
			return;
		}
		
		var jmc_3letter=$(city).value.substring(0,3);
		if(hotelCityGroup[0] == null || hotelCityGroup[0][jmc_3letter]== null)
			return;
		var arr = hotelCityGroup[0][jmc_3letter];
		for(var i = 0; i < arr.length;i++){	
			$(landmark).options.add(new Option(arr[i].name.unEscapeHTML(),arr[i].code));
		}
		if(defaultValue != null && defaultValue != "") {
			$(landmark).value = defaultValue;
		}
	}
	
	
	function hotelChangeValue(id, value){
		if( value != null || value != '' || id!=null){
			$(id).value = value.unEscapeHTML();
		}
	}
		
	function hotelHiddenValue(seniMotoCode_value,PageFormName_value){
		if (seniMotoCode_value!=""){
			$('seniMotoCode').value=seniMotoCode_value;
		}
		if (PageFormName_value!=null){
		
			$('PageFormName').value=PageFormName_value;
		}
	}
	
	function del_sts (){
		if ($('research_sts')!=null){
			$('research_sts').value="";
		}
		if ($('userAppraise_sts')!=null){
			$('userAppraise_sts').value="";
		}
		if ($('hotelName_sts')!=null){
			$('hotelName_sts').value="";
		}
		if ($('equipment_service_sts')!=null){
			$('equipment_service_sts').value="";
		}	
	}
	
	function doHotelSubmit(method,actionPath){
		actionPath = httpPath + actionPath;
		$('cm').value = method;
		document.forms[0].action = actionPath;
		document.forms[0].submit();
	}