var initCityInput=function(n,t){var f={hot:["北京","上海","广州","深圳","成都","重庆","西安","杭州","武汉","南京","沈阳","天津","大连","青岛","长沙","昆明","长春","郑州","海口","合肥","济南","福州","哈尔滨","乌鲁木齐"]},i=$("#cityList"+t),r=t=="From"?"0":"1",e=$("ul.cityContent",i),u;for(n.add("#cityOpen"+t).click(function(n){$("#flight"+t).hasClass("errorInput")&&$("#flight"+t).removeClass("errorInput").unbind("focus").val("");i.is(":visible")?(i.hide(),Statistics.trigger(7,r,"1")):(i.show(),$("#cityList"+(t=="From"?"To":"From")).hide(),Statistics.trigger(7,r,"0"));n.stopPropagation()}),$("#cityClose"+t).click(function(n){i.hide();Statistics.trigger(9,r);n.stopPropagation()}),e.empty(),u=0;u<f.hot.length;u++)$("<li>").text(f.hot[u]).appendTo(e);i.click(function(n){if(n.target.tagName=="LI"){var u=$(n.target).text();$("#flight"+t).focus().val(u);InputKeeper.keep(t.toLowerCase(),u);i.hide();$(n.target).parent().hasClass("cityHistory")?Statistics.trigger(39,r,encodeURIComponent(u)):Statistics.trigger(8,r,encodeURIComponent(u))}});n.click(function(){$(this).select()});n.textext({plugins:"autocomplete prompt",autocomplete:{dropdownMaxHeight:"160px",render:function(n){return'<label class="text-label text-label-left">'+n[0]+'<\/label>  <label class="text-label text-label-right">'+n[1]+"<\/label>"}},prompt:t=="From"?"出发地":"目的地",itemManager:function(){return{compareItems:function(n,t){return n[0]==t[0]},filter:function(t,i){for(var u=[],f=i.replace(/\s/g,"").toLowerCase(),r=t.length-1,e=n.siblings(".text-dropdown");r>=0;r--)(t[r][0].indexOf(f)===0||t[r][2].indexOf(f)===0||t[r][3].indexOf(f)===0)&&u.push(t[r]);return u.length>4?n.siblings(".text-dropdown").getNiceScroll().show().resize():n.siblings(".text-dropdown").getNiceScroll().hide(),u},itemToString:function(n){return Statistics.trigger(38,r,encodeURIComponent(n[0])),InputKeeper.keep(t.toLowerCase(),n[0]),n[0]},init:function(){},stringToItem:function(){}}}}).bind("getSuggestions",function(n,i){var r=$(n.target).textext()[0],u=(i?i.query:"")||"";$("#cityList"+(t=="From"?"From":"To")).hide();$(this).trigger("setSuggestions",{result:r.itemManager().filter(CityMap.PinYin,u)})});n.siblings(".text-dropdown").niceScroll({cursoropacitymin:.2,cursoropacitymax:.4,cursorwidth:"6px"})}