function startNewSearch(controls) {
	Event.fire(System,"beforeSearch");
	f_bD = doSearch.bind(this,controls);
	Event.observe(controls,"checkpassed",f_bD);
	Event.observe(controls,"checkfailed",null);
	controls.checkAll();
}


function doSearch(_controls) {
	var formDate = $("hinpFromDate").value;
	var toDate = $("hinpToDate").value;
	var toCity = $("hinpToCity").value;
	var q = $("jxQ").value;
	if(q == "酒店名或地址(可选)"){
		q = "";
	}
	location.href = "http://hotel.qunar.com/search.jsp?fromDate=" + formDate + "&toDate=" + toDate + "&toCity=" + toCity + "&q=" + q + "&_VTYPE=map&from=huochepiao";
}
function system_onload() {
	Object.extend(System.language, languageVars);
	var controlDef = $H({
		datepicker : $A([{ 
			id 			: "hdatFromDate",
			targetInput	: "hinpFromDate",
			dateOffset: 2,
			linkDP	: "hinpToDate",
			linkOffset : 3,
			template_container: templates.datepicker_container,
			template_main: templates.datepicker_main,
			pickerImg: "himgFromDate",
			specLinkDp:"hinpToDate",
			disinput: "hinpFromDate_dis",
			calendarMode:2
		},{ 
			id 			: "hdatToDate",
			targetInput	: "hinpToDate",
			dateOffset: 5,
			template_container: templates.datepicker_container,
			template_main:templates.datepicker_main,
			pickerImg: "himgToDate",
			disinput: "hinpToDate_dis",
			calendarMode:2
		}]), 	
		cityinput : $A([{
			id: "hinpToCity",
			options: {
			useSuggest: true,
			useValidate: true,
			validateURL: System.constant.VALIDATE_URL,
			language: System.currentLanguage,
			suggestShowAirport: false,
			suggestTemplateObj: templates.suggest,
			useHotCity: true,
			hotCityImage: "himgArriHotCity",
			hotCityList : System.language._HOT_CITY_LIST,
			hotCityTemplateObj: templates.hotcity
		}
		}]),
		htmlformelement: $A ([
							  {
								  id: "jxQ"
							  }
							  ])
	});
	var cg = new ControlGroup(controlDef);

	
	System.status = {
		language : "zh",
		pageAbbr : "FH"
	};
	Event.observe("hbtnSearch","click",startNewSearch.bind(null,cg));
	Event.observe("jxQ","focus",function(){
		if($("jxQ").value == "酒店名或地址(可选)"){
			$("jxQ").value = "";
		}else{
			$("jxQ").style.color = "#000";
		}
	});
	Event.observe("jxQ","keydown",function(){
		$("jxQ").style.color = "#000";
	});
	Event.observe("jxQ","blur",function(){
		if($("jxQ").value.trim() == ""){
			$("jxQ").value = "酒店名或地址(可选)";
			$("jxQ").style.color = "#ccc";
		}
	});
	setTab(0,0);
	setTab(1,0);
}
function setTab(m,n){
	var lis = $("hotelTabs" + m).getElementsByTagName("li");
	var lists = $("hotelList" + m).getElementsByTagName("div");
	var listArr = [];
	for(var i = 0;i < lists.length;i++){
		if(lists[i].className == "ct"){
			listArr.push(lists[i]);
		}
	}
	for(var i = 0 ;i < lis.length;i++){
		var hl = $(lis[i]);
		var la = $(listArr[i]);
		if(i == n){
			hl.addClassName("active");
			if(la){
				la.show();
			}
		}else{
			hl.removeClassName("active");
			if(la){
				la.hide();
			}
		}
	}
}