var base_page='';
var global_select_time_callback=changColor;
$(function(){

		  /**
    $('#i-date,#i-rdate').each(function(){
					 $(this).click(function(event){
									$(document).click();
									 $(this).css('color','#808080');
									 if($.trim($(this).val())=='yyyy-mm-dd') $(this).val('');
									 if($(this).attr('id')=='i-date') {
										showKXCalendar(event,'i-date');
									 }else {
										 showKXCalendar(event,'i-rdate','i-date');
									 }

									  })
						 if($.trim($(this).val()).length==0){$(this).val('yyyy-mm-dd').css('color','#bbb');}
	 })
	/**/
})

    //阻止浏览器的默认行为
    function stopDefault( e ) {
        //阻止默认浏览器动作(W3C)
        if ( e && e.preventDefault ){
            e.preventDefault();
			 e.stopPropagation();
		}
        //IE中阻止函数器默认动作的方式
        else{
            window.event.returnValue = false;
			window.event.cancelBubble = true;
		}
        return false;
    }

function initPopCity(input_id,img_id,input2_id,callback){
	if($("#"+input_id).length==0) return;
	input2_id=input2_id?input2_id:null;
	var o_input_j=$('#'+input_id);
	o_input_j.focus(function(){
						   City.clearDefault(this, true, 0);
		   }).blur(function(){
			  City.clearDefault(this, false, 0);
		  }).click(function(){
			  City.show(this, input2_id,{callback:callback});
		  }).keyup(function(event){
			  City.suggest(this,event);
		  });
   if($('#'+img_id).length>0){
	  $('#'+img_id).click(function(event){$('#'+input_id).click();event.stopPropagation();});
   }
}
var showKXCalendar=function(event,id,rid){
	/**
	    if(rid)
		KX.Fp.showCalendar(id,false,id, null, calcallbackjp,rid);
		else
		KX.Fp.showCalendar(id,false,id, null, calcallbackjp);
		event.stopPropagation();
	/**/
	//
		return false;
}
function checkFormCity(fromcity,tocity){
   var city1=$.trim($('#'+fromcity).val());
   var city2=$.trim($('#'+tocity).val());

    if(city1.length==0||city1=='城市名') {showBox('请输入出发城市','',function(){$('#'+fromcity).click();});return false;}
    if(city2.length==0||city2=='城市名') {showBox('请输入到达城市','',function(){$('#'+tocity).click();});return false;}
    if(city1==city2){showBox('出发城市和目的城市不能相同','',function(){$('#'+tocity).click();});return false;}
	if(!isValideCity(city1)){
		showBox('出发城市不存在，请重新选择',function(){$('#'+fromcity).focus();});
		return false;
	}
	if(!isValideCity(city2)){
		showBox('到达城市不存在，请重新选择',function(){$('#'+tocity).focus();});
		return false;
	}
	return true;
}
function checkFormDate(todate,returndate,has_return){
   var date1=$.trim($('#'+todate).val());
   var date2=$.trim($('#'+returndate).val());

	var d=new Date();
    var month=d.getMonth()+1;
	if(month<10) month='0'+month;

	var date=d.getDate();
	if(date<10) date='0'+date;

	var today=d.getFullYear()+'-'+month+'-'+date;

	var p=/^\d{4}-\d{2}-\d{1,2}$/;
    if(date1.length==0||date1=='yyyy-mm-dd') {showBox('请选择出发日期','',function(){$('#'+todate).focus();});return false;}
    if(!p.test(date1)) {showBox('出发日期格式错误','',function(){$('#'+todate).click();});return false;}
    if(parseInt(date1.replace("-","").replace("-",""))<parseInt(today.replace("-","").replace("-",""))) {showBox('出发日期不能小于当前日期','',function(){$('#'+todate).click();});return false;}

   if(has_return==2){
		if(date2.length==0||date2=='yyyy-mm-dd') {showBox('请选择返回日期','',function(){$('#'+returndate).focus();});return false;}
		if(!p.test(date2)) {showBox('返回日期格式错误','',function(){$('#'+returndate).click();});return false;}
		if(parseInt(date2.replace("-","").replace("-",""))<parseInt(date1.replace("-","").replace("-",""))) {showBox('返回日期不能小于出发日期','',function(){$('#'+returndate).click();});return false;}
   }

	return true;
}
/**fromcity,tocity,todate参数不能为空
*/
function checkCityDate(fromcity,tocity,todate,returndate,has_return){
   var city1=$.trim($('#'+fromcity).val());
   var city2=$.trim($('#'+tocity).val());
   var date1=$.trim($('#'+todate).val());
   var date2=$.trim($('#'+returndate).val());


    if(city1.length==0||city1=='城市名') {showBox('请输入出发城市','',function(){$('#'+fromcity).click();});return false;}
    if(city2.length==0||city2=='城市名') {showBox('请输入到达城市','',function(){$('#'+tocity).click();});return false;}
    if(city1==city2){showBox('出发城市和目的城市不能相同','',function(){$('#'+tocity).click();});return false;}
	if(!isValideCity(city1)){
		showBox('出发城市不存在，请重新选择',function(){$('#'+fromcity).focus();});
		return false;
	}
	if(!isValideCity(city2)){
		showBox('到达城市不存在，请重新选择',function(){$('#'+tocity).focus();});
		return false;
	}
	var d=new Date();
    var month=d.getMonth()+1;
	if(month<10) month='0'+month;
	var today=d.getFullYear()+'-'+month+'-'+d.getDate();
	var p=/^\d{4}-\d{2}-\d{1,2}$/;
    if(date1.length==0||date1=='yyyy-mm-dd') {showBox('请选择出发日期','',function(){$('#'+todate).focus();});return false;}
    if(!p.test(date1)) {showBox('出发日期格式错误','',function(){$('#'+todate).click();});return false;}
    if(date1<today) {showBox('出发日期不能小于当前日期','',function(){$('#'+todate).click();});return false;}

   if(has_return==2){
		if(date2.length==0||date2=='yyyy-mm-dd') {showBox('请选择返回日期','',function(){$('#'+returndate).focus();});return false;}
		if(!p.test(date2)) {showBox('返回日期格式错误','',function(){$('#'+returndate).click();});return false;}
		if(date2<date1) {showBox('返回日期不能小于出发日期','',function(){$('#'+returndate).click();});return false;}
   }

	return true;
}

function emptyCity(t,city){
	if(t==1){
		showBox("您输入的出发城市不存在,请重新输入。",function(){
											  if(typeof removeLoading=='function' )
											     removeLoading();
											  $("#frmcity").val("").focus();
											 });
	}else{
		showBox("您输入的到达城市不存在,请重新输入。",function(){
											  if(typeof removeLoading=='function' )
											     removeLoading();
											  $("#tocity").val("").focus();});
	}
}
/**通过航空公司代号获取航空公司名
**/
function getAirCompanyByPlaneId(planeno,def_name){
	    planeno=planeno.toUpperCase();
		var _planeComp={'CA':'国际航空','CJ':'北方航空','CZ':'南方航空','SZ':'西南航空','WH':'西北航空','MU':'东方航空','MF':'厦门航空','SC':'山东航空','FM':'上海航空','4G':'深圳航空','X2':'新华航空','F6':'航空股份','3Q':'云南航空','XO':'新疆航空','3U':'四川航空','Z2':'中原航空','WU':'武汉航空','G4':'贵州航空','H4':'海南航空','GP':'通用航空','3W':'南京航空','ZJ':'浙江航空','GW':'长城航空','FJ':'福建航空','2Z':'长安航空','HU':'海南航空','ZH':'深圳航空','PN':'西部航空','JD':'金鹿航空'};
		if(typeof _planeComp[planeno]!='undefined'){
			var comp=_planeComp[planeno];
			//var comp=tmp_plane.SW_AIRCOMPANY;
		}else{
			var comp=def_name||'';
		}
		return comp;
}

function addLoading(container){
	      //  removeLoading();
		  // $('.loading_img').css('display','block');
		 var geo=getPosition($('#'+container)[0]);
			var x=(geo.left+$('#'+container)[0].offsetWidth/2)+'px',y=(geo.top+10)+'px';
			$('.loading_img').css({'display':'block','left':x,'top':y});
			//$('.loading_img').css({'display':'block','left':'770px','top':'400px'});alert('hi');
}
function removeLoading(){
	 $('.loading_img').css('display','none');
}

 function stopBubble(e) {
        //如果提供了事件对象，则这是一个非IE浏览器
        if ( e && e.stopPropagation )
            //因此它支持W3C的stopPropagation()方法
            e.stopPropagation();
        else
            //否则，我们需要使用IE的方式来取消事件冒泡
            window.event.cancelBubble = true;
    }
    //阻止浏览器的默认行为
    function stopDefault( e ) {
        //阻止默认浏览器动作(W3C)
        if ( e && e.preventDefault )
            e.preventDefault();
        //IE中阻止函数器默认动作的方式
        else
            window.event.returnValue = false;
        return false;
    }
var cities_hot=['北京','合肥','广州','深圳','武汉','杭州','成都','西安','南京','长沙','沈阳','厦门','海口','青岛','大连','石家庄','郑州','银川','长春','贵阳','桂林','天津','太原','福州','哈尔滨','乌鲁木齐','上海浦东','上海虹桥'];
	cities_hot.sort(function(str1, str2){ return str1.localeCompare(str2); })

var cities={"a":[{"a":"\u963f\u514b\u82cf","b":"AKeSu","c":"AKU"},{"a":"\u963f\u52d2\u6cf0","b":"ALeTai","c":"AAT"},{"a":"\u5b89\u5eb7","b":"AnKang","c":"AKA"},{"a":"\u5b89\u5e86","b":"AnQing","c":"AQG"},{"a":"\u978d\u5c71","b":"AnShan","c":"AOG"},{"a":"\u5b89\u987a","b":"AnShun","c":"AVA"},{"a":"\u5b89\u9633","b":"AnYang","c":"AYN"}],"b":[{"a":"\u4fdd\u5c71","b":"BaoShan","c":"BSD"},{"a":"\u5305\u5934","b":"BaoTou","c":"BAV"},{"a":"\u5317\u6d77","b":"BeiHai","c":"BHY"},{"a":"\u5317\u4eac\u5357\u82d1","b":"BeiJingNanYuan","c":"NAY"},{"a":"\u5317\u4eac","b":"BeiJingShouDu","c":"PEK"},{"a":"\u868c\u57e0","b":"BengBu","c":"BFU"}],"c":[{"a":"\u957f\u6625","b":"ChangChun","c":"CGQ"},{"a":"\u5e38\u5fb7","b":"ChangDe","c":"CGD"},{"a":"\u660c\u90fd","b":"ChangDu","c":"BPX"},{"a":"\u957f\u6d77","b":"ChangHai","c":"CNI"},{"a":"\u957f\u6c99","b":"ChangSha","c":"CSX"},{"a":"\u957f\u6cbb","b":"ChangZhi","c":"CIH"},{"a":"\u5e38\u5dde","b":"ChangZhou","c":"CZX"},{"a":"\u671d\u9633","b":"ChaoYang","c":"CHG"},{"a":"\u627f\u5fb7","b":"ChengDe","c":"CEH"},{"a":"\u6210\u90fd","b":"ChengDu","c":"CTU"},{"a":"\u8d64\u5cf0","b":"ChiFeng","c":"CIF"},{"a":"\u91cd\u5e86","b":"ChongQing","c":"CKG"}],"d":[{"a":"\u5927\u7406","b":"DaLi","c":"DLU"},{"a":"\u5927\u8fde","b":"DaLian","c":"DLC"},{"a":"\u4e39\u4e1c","b":"DanDong","c":"DDG"},{"a":"\u5927\u5e86","b":"DaQing","c":"DQA"},{"a":"\u5927\u540c","b":"DaTong","c":"DAT"},{"a":"\u8fbe\u53bf","b":"DaXian","c":"DAX"},{"a":"\u5927\u8db3","b":"DaZu","c":"DZU"},{"a":"\u8fea\u5e86","b":"DiQing","c":"DIG"},{"a":"\u4e1c\u839e","b":"DongGuan","c":"DGM"},{"a":"\u4e1c\u80dc","b":"DongSheng","c":"DSN"},{"a":"\u4e1c\u8425","b":"DongYing","c":"DOY"},{"a":"\u6566\u714c","b":"DunHuang","c":"DNH"}],"e":[{"a":"\u9102\u5c14\u591a\u65af","b":"EErDuoS","c":"DSN"},{"a":"\u6069\u65bd","b":"EnShi","c":"ENH"}],"f":[{"a":"\u4f5b\u5c71","b":"FoShan","c":"ZCP"},{"a":"\u961c\u9633","b":"FuYang","c":"FUG"},{"a":"\u5bcc\u8574","b":"FuYun","c":"FYN"},{"a":"\u798f\u5dde","b":"FuZhou","c":"FOC"}],"g":[{"a":"\u8d63\u5dde","b":"GanZhou","c":"KOW"},{"a":"\u683c\u5c14\u6728","b":"GeErMu","c":"GOQ"},{"a":"\u5e7f\u6c49","b":"GuangHan","c":"GHN"},{"a":"\u5e7f\u5143","b":"GuangYuan","c":"GYS"},{"a":"\u5e7f\u5dde","b":"GuangZhou","c":"CAN"},{"a":"\u6842\u6797","b":"GuiLin","c":"KWL"},{"a":"\u8d35\u9633","b":"GuiYang","c":"KWE"}],"h":[{"a":"\u54c8\u5c14\u6ee8","b":"HaErBin","c":"HRB"},{"a":"\u6d77\u53e3","b":"HaiKou","c":"HAK"},{"a":"\u6d77\u62c9\u5c14","b":"HaiLaEr","c":"HLD"},{"a":"\u54c8\u5bc6","b":"HaMi","c":"HMI"},{"a":"\u90af\u90f8","b":"HanDan","c":"HDG"},{"a":"\u676d\u5dde","b":"HangZhou","c":"HGH"},{"a":"\u6c49\u4e2d","b":"HanZhong","c":"HZG"},{"a":"\u5408\u80a5","b":"HeHei","c":"HFE"},{"a":"\u9ed1\u6cb3","b":"HeiHe","c":"HEK"},{"a":"\u8861\u9633","b":"HengYang","c":"HNY"},{"a":"\u548c\u7530","b":"HeTian","c":"HTN"},{"a":"\u6000\u5316","b":"HuaiHua","c":"HJJ"},{"a":"\u9ec4\u5c71","b":"huangshan","c":"TXN"},{"a":"\u9ec4\u5ca9","b":"HuangYan","c":"HYN"},{"a":"\u547c\u548c\u6d69\u7279","b":"HuHeHaoTe","c":"HET"},{"a":"\u5fbd\u5dde","b":"HuiZhou","c":"HUZ"}],"j":[{"a":"\u4f73\u6728\u65af","b":"JiaMuSi","c":"JMU"},{"a":"\u5409\u5b89","b":"JiAn","c":"KNC"},{"a":"\u5609\u5cea\u5173","b":"JiaYuGuan","c":"JGN"},{"a":"\u5409\u6797","b":"JiLin","c":"JIL"},{"a":"\u6d4e\u5357","b":"JiNan","c":"TNA"},{"a":"\u666f\u5fb7\u9547","b":"JingDeZhen","c":"JDZ"},{"a":"\u4e95\u5188\u5c71","b":"jingGangShan","c":"JGS"},{"a":"\u666f\u6d2a","b":"JingHong","c":"JHG"},{"a":"\u8346\u5dde","b":"JingZhou","c":"SHS"},{"a":"\u6d4e\u5b81","b":"JiNing","c":"JNG"},{"a":"\u664b\u6c5f","b":"JinJiang","c":"JJN"},{"a":"\u9526\u5dde","b":"JinZhou","c":"JNZ"},{"a":"\u4e5d\u6c5f","b":"JiuJiang","c":"JIU"},{"a":"\u9152\u6cc9","b":"JiuQuan","c":"CHW"},{"a":"\u4e5d\u5be8\u6c9f","b":"JiuZhaiGou","c":"JZH"}],"k":[{"a":"\u5580\u4ec0","b":"KaShi","c":"KHG"},{"a":"\u514b\u62c9\u739b\u4f9d","b":"KeLaMaYi","c":"KRY"},{"a":"\u5e93\u8f66","b":"KuChe","c":"KCA"},{"a":"\u5e93\u5c14\u52d2","b":"KuErLe","c":"KRL"},{"a":"\u6606\u660e","b":"KunMing","c":"KMG"},{"a":"\u6606\u5c71","b":"KunShan","c":"KUS"}],"l":[{"a":"\u5170\u5dde","b":"LanZhou","c":"LHW"},{"a":"\u62c9\u8428","b":"LaSa","c":"LXA"},{"a":"\u8fde\u57ce","b":"LianCheng","c":"LCX"},{"a":"\u6881\u5e73","b":"LiangPing","c":"WXN"},{"a":"\u8fde\u4e91\u6e2f","b":"LianYunGang","c":"LYG"},{"a":"\u4e3d\u6c5f","b":"LiJiang","c":"LJG"},{"a":"\u4e34\u6ca7","b":"LinCang","c":"LNJ"},{"a":"\u6797\u897f","b":"LinXi","c":"LXI"},{"a":"\u4e34\u6c82","b":"LinYi","c":"LYI"},{"a":"\u6797\u829d","b":"LinZhi","c":"LZY"},{"a":"\u67f3\u5dde","b":"LiuZhou","c":"LZH"},{"a":"\u9f99\u5ca9","b":"LongYan","c":"LCX"},{"a":"\u7f57\u5b9a","b":"LuoDing","c":"LDG"},{"a":"\u6d1b\u9633","b":"LuoYang","c":"LYA"},{"a":"\u5e90\u5c71","b":"LuShan","c":"LUZ"},{"a":"\u6cf8\u5dde","b":"LuZhou","c":"LZO"}],"m":[{"a":"\u8292\u5e02","b":"MangShi","c":"LUM"},{"a":"\u6ee1\u6d32\u91cc","b":"ManZhouLi","c":"NZH"},{"a":"\u6885\u53bf","b":"MeiXian","c":"MXZ"},{"a":"\u7ef5\u9633","b":"MianYang","c":"MIG"},{"a":"\u7261\u4e39\u6c5f","b":"MuDanJiang","c":"MDG"}],"n":[{"a":"\u5357\u660c","b":"NanChang","c":"KHN"},{"a":"\u5357\u5145","b":"NanChong","c":"NAO"},{"a":"\u5357\u4eac","b":"NanJing","c":"NKG"},{"a":"\u5357\u5b81","b":"NanNing","c":"NNG"},{"a":"\u5357\u5e73","b":"NanPing","c":"WUS"},{"a":"\u5357\u901a","b":"NanTong","c":"NTG"},{"a":"\u5357\u9633","b":"NanYang","c":"NNY"},{"a":"\u5b81\u6ce2","b":"NingBo","c":"NGB"}],"p":[{"a":"\u6500\u679d\u82b1","b":"PanZhiHua","c":"PZI"},{"a":"\u666e\u6d31","b":"PuEr","c":"SYM"}],"q":[{"a":"\u4e14\u672b","b":"QeMo","c":"IQM"},{"a":"\u9752\u5c9b","b":"QingDao","c":"TAO"},{"a":"\u5e86\u9633","b":"QingYang","c":"IQN"},{"a":"\u79e6\u7687\u5c9b","b":"QinHuangDao","c":"SHP"},{"a":"\u9f50\u9f50\u54c8\u5c14","b":"QiQiHaEr","c":"NDG"},{"a":"\u8862\u5dde","b":"QuZhou","c":"JUZ"}],"s":[{"a":"\u4e09\u4e9a","b":"SanYa","c":"SYX"},{"a":"\u4e0a\u6d77\u8679\u6865","b":"ShangHaiHongQiao","c":"SHA"},{"a":"\u4e0a\u6d77\u6d66\u4e1c","b":"ShangHaiPuDong","c":"PVG"},{"a":"\u5c71\u6d77\u5173","b":"ShanHaiGuan","c":"SHP"},{"a":"\u912f\u5584","b":"ShanShan","c":"SSA"},{"a":"\u6c55\u5934","b":"ShanTou","c":"SWA"},{"a":"\u6c99\u5e02","b":"ShaShi","c":"SHS"},{"a":"\u6c88\u9633","b":"ShenYang","c":"SHE"},{"a":"\u6df1\u5733","b":"ShenZhen","c":"SZX"},{"a":"\u77f3\u5bb6\u5e84","b":"ShiJiaZhuang","c":"SJW"},{"a":"\u601d\u8305","b":"SiMao","c":"SYM"},{"a":"\u82cf\u5dde","b":"SuZhou","c":"SZV"}],"t":[{"a":"\u5854\u57ce","b":"TaCheng","c":"TCG"},{"a":"\u592a\u539f","b":"TaiYuan","c":"TYN"},{"a":"\u5929\u6d25","b":"TianJin","c":"TSN"},{"a":"\u901a\u5316","b":"TongHua","c":"TNH"},{"a":"\u901a\u8fbd","b":"TongLiao","c":"TGO"},{"a":"\u94dc\u4ec1","b":"TongRen","c":"TEN"}],"w":[{"a":"\u4e07\u5dde","b":"WanZhou","c":"WXN"},{"a":"\u6f4d\u574a","b":"WeiFang","c":"WEF"},{"a":"\u5a01\u6d77","b":"WeiHai","c":"WEH"},{"a":"\u6e29\u5dde","b":"WenZhou","c":"WNZ"},{"a":"\u4e4c\u6d77","b":"WuHai","c":"WUA"},{"a":"\u6b66\u6c49","b":"WuHan","c":"WUH"},{"a":"\u829c\u6e56","b":"WuHu","c":"ZSWU"},{"a":"\u4e4c\u5170\u6d69\u7279","b":"WuLanHaoTe","c":"HLH"},{"a":"\u4e4c\u9c81\u6728\u9f50","b":"WuLuMuQi","c":"URC"},{"a":"\u65e0\u9521","b":"WuXi","c":"WUX"},{"a":"\u6b66\u5937\u5c71","b":"WuYiShan","c":"WUS"},{"a":"\u68a7\u5dde","b":"WuZhou","c":"WUZ"}],"x":[{"a":"\u53a6\u95e8","b":"XiaMen","c":"XMN"},{"a":"\u897f\u5b89","b":"XiAn","c":"XIY"},{"a":"\u8944\u6a0a","b":"XiangFan","c":"XFN"},{"a":"\u897f\u660c","b":"XiChang","c":"XIC"},{"a":"\u5174\u57ce","b":"XingCheng","c":"XEN"},{"a":"\u5174\u5b81","b":"XingNing","c":"XIN"},{"a":"\u90a2\u53f0","b":"XingTai","c":"XNT"},{"a":"\u897f\u5b81","b":"XiNing","c":"XNN"},{"a":"\u897f\u53cc\u7248\u7eb3","b":"XiShuangBanNa","c":"JHG"},{"a":"\u9521\u6797\u6d69\u7279","b":"XLlinHaoTe","c":"XIL"},{"a":"\u5f90\u5dde","b":"XuZhou","c":"XUZ"}],"y":[{"a":"\u5ef6\u5b89","b":"YaNan","c":"ENY"},{"a":"\u76d0\u57ce","b":"YanCheng","c":"YNZ"},{"a":"\u5ef6\u5409","b":"YanJi","c":"YNJ"},{"a":"\u70df\u53f0","b":"YanTai","c":"YNT"},{"a":"\u5b9c\u5bbe","b":"YiBin","c":"YBP"},{"a":"\u5b9c\u660c","b":"YiChang","c":"YIH"},{"a":"\u4f9d\u5170","b":"YiLan","c":"ZYYL"},{"a":"\u94f6\u5ddd","b":"YinChuan","c":"INC"},{"a":"\u4f0a\u5b81","b":"YiNing","c":"YIN"},{"a":"\u4e49\u4e4c","b":"YiWu","c":"YIW"},{"a":"\u6c38\u5dde","b":"YongZhou","c":"LLF"},{"a":"\u5143\u8c0b","b":"YuanMou","c":"YUA"},{"a":"\u6986\u6797","b":"YuLin","c":"UYN"},{"a":"\u8fd0\u57ce","b":"YunCheng","c":"YCU"}],"z":[{"a":"\u5f20\u5bb6\u754c","b":"ZhangJiaJie","c":"DYG"},{"a":"\u6e5b\u6c5f","b":"ZhanJiang","c":"ZHA"},{"a":"\u8087\u5e86","b":"ZhaoQing","c":"ZHQ"},{"a":"\u662d\u901a","b":"ZhaoTong","c":"ZAT"},{"a":"\u90d1\u5dde","b":"ZhengZhou","c":"CGO"},{"a":"\u821f\u5c71","b":"ZhouShan","c":"HSN"},{"a":"\u73e0\u6d77","b":"ZhuHai","c":"ZUH"},{"a":"\u9075\u4e49","b":"ZunYi","c":"ZYI"}]}
function isValideCity(city){
	var t=false;
  	for(var i=65;i<=90;i++){
	   var alpha=String.fromCharCode(i).toLowerCase();
	   var tmp_arr=cities[alpha];

	   if(!tmp_arr) continue;
	   for(var j=0,l=tmp_arr.length;j<l;j++){
		   if(city==tmp_arr[j].a){
			t=true;
			break;
		   }
	   }
	   if(t) break;
	}
	return t;
}

var citycodelistmore=new Array("PEK","SHA","CAN","SZX","CTU","XIY","HGH","HRB","WUH","CSX","TSN","SHE","CGQ","DLC","TAO","TNA","CGO","TYN","NKG","SJW","NGB","FOC","XMN","ZUH","HAK","KHN","HFE","NNG");
var citynamelistmore=new Array("北京","广州","深圳","成都","西安","杭州","哈尔滨","武汉","长沙","天津","沈阳","长春","大连","青岛","济南","郑州","太原","南京","石家庄","宁波","福州","厦门","珠海","海口","南昌","合肥","南宁");
function getspanLeft(x){var l=0;while(x){l+=x.offsetLeft;x=x.offsetParent;}return l;}
function gETop(x) {var t = 0;while(x) {t += x.offsetTop;x = x.offsetParent;} return t;}
function ltrim(s){
    return s.replace( /^\s*/,"");
}
function rtrim(s){
    return s.replace( /\s*$/,"");
}
function trim(s){
    return ltrim(rtrim(s));
}


/**
* 调用方法：onClick="showAllCities(this.id,'',event,null,'left');"
* 第一个参数是单击对象的id，第二个参数是当前的开始的字母，第三个是现场事件对象，第四个是需要赋值的div或者span,第五个是左上角定位或右上角定位
**/
var cities_index=new Array();
function findCityLetter(city){
	for(var oa in cities){
	   for(var i=0;i<cities[oa].length;i++){
		     if(city==cities[oa][i].a){
				return oa;
			 }
	   }
	}
	return "";
}
function showmorectiy2(input,alpha,e,result_id,pos_corner){
	 var e=e||window.event;
	 e.cancelBubble = true;
      $(document).click(function(){if($('#hot_cities_table').length>0) $('#hot_cities_table').remove();});
	  if($('#hot_cities_table').length>0) $('#hot_cities_table').remove();
	  var now_city='';

	   if((alpha.length==0) && typeof result_id!='undefined' && result_id!='null'){
		    now_city=$.trim($('#'+result_id).html());
		  for(var c in cities_index){
			 if(c==now_city){
			  	 alpha=cities_index[c];flag=true;
				 break;
			  }
		   }
		   if(!flag){
			  alpha=findCityLetter(v);
		   }
	    }else{
		   now_city=$.trim($('#'+input).val());
	    }


	  if(alpha.length==0 && $.trim($('#'+input).val()).length>0){
		   var v=$.trim($('#'+input).val());
		   now_city=v;
		  var flag=false;
		  for(var c in cities_index){
			if(c==v){
			  	 var alpha=cities_index[c];flag=true;
				 break;
			}
		  }
		  if(!flag){
			  var alpha=findCityLetter(v);
		  }
	  }
	  if(alpha.length==0){
		   var alpha='a';
	  }

          var tc=cities[alpha.toLowerCase()];
          var ts=new Array();
          ts.push('<table id="hot_cities_table" style="display:none;">');
		  ts.push('<tr><td class="title">请选择城市</td></tr>');
		  ts.push('<tr><td class="title_hotcities">&nbsp;&nbsp;<b>热门城市:</b>');
		  var h_c_a=new Array('深圳','北京','上海','广州','重庆','武汉','成都','西安');
		  for(var i=0;i<h_c_a.length;i++){
			 ts.push('<span onclick="setLastTab(\''+result_id+'\',\''+h_c_a[i]+'\');$(\'#hot_cities_table\').remove();">'+h_c_a[i]+'</span>');
		  }
		  ts.push('</td></tr><tr><td id="hot_cities_title">'+getAllCitiesNav(input,alpha,result_id,pos_corner)+'</td></tr>');
          ts.push('<tr><td id="hot_cities_content">');
          ts.push('<table id="hot_cities_list">');
          if(!tc){//如果没有城市记录
            ts.push('<tr rowspan="3"><td colspan="6" class="hot_cities_none">没有相关城市信息</td></tr></table>');
                  $('body').append(ts.join(''));
             setAllCitiesStyle(input,alpha,result_id,pos_corner)
                 return;
          }
          for(var i=0,r=0,j=tc.length;i<j;i++){//以某一个字母开头的城市展示出来
            var o=tc[i];
                if(i%6==0){//每行展示6个
                  ts.push('</tr><tr>');
                  r++;//table's row行数
                }
                ts.push('<td class="hotcity');
                if(o.a==now_city){
                  ts.push(' cur_city ');
                }
                ts.push('" onclick="assignCity(\''+input+'\',\''+o.a+'\',this,\''+alpha+'\',\''+result_id+'\');event.cancelBubble = true;">'+o.a+'</td>');

          }//end for
          if(i%6==1) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==2) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==3) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==4) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==5) ts.push('<td >&nbsp;&nbsp;</td></tr>');

          if(r==1){
            ts.push('<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
            ts.push('<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          }else if(r==2){
            ts.push('<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          }
          ts.push('</table>');
          ts.push('</td></tr></table>');
          $('body').append(ts.join(''));
          $('#hot_cities_table').click(function(){return false;})
          $('td.hotcity',$('#hot_cities_list')).hover(function(){$(this).addClass('over');},function(){$(this).removeClass('over');})
          setAllCitiesStyle(input,alpha,result_id,pos_corner)

}

function assignCity(input,city,td_obj,alpha,result_id){
    if($(td_obj).length>0){
		$('td.cur_city',$('#hot_cities_list')).removeClass('cur_city');
		$(td_obj).addClass('cur_city');
	}
    cities_index[$(td_obj).text()]=alpha;
	if(result_id!=undefined && result_id!='undefined' && result_id!='null'){
		if(typeof setLastTab=='function') setLastTab(result_id,city);
	}else{
		$('#'+input).val(city);
	}
     $('#hot_cities_table').remove();

}
function setAllCitiesStyle(input,alpha,result_id,pos_corner){
          getAllCitiesNav(input,alpha,result_id);
          var p=$('#'+input).offset();
          var h=$('#'+input)[0].offsetHeight;
          var w=$('#'+input)[0].offsetWidth;
          var left=p.left;
          var tw=$('#hot_cities_table').outerWidth()
          var bw=$('body').outerWidth();
		  if(pos_corner=='right'){
		     $('#hot_cities_table').css({'left':(left-tw+w)+'px','top':(p.top+h)+'px','display':''});
			return false;
		  }
		  if(pos_corner=='left'){
          $('#hot_cities_table').css({'left':p.left+'px','top':(p.top+h)+'px','display':''});
			return false;
		  }
          if((bw-left)>tw ){
          $('#hot_cities_table').css({'left':p.left+'px','top':(p.top+h)+'px','display':''});
          }else{
           $('#hot_cities_table').css({'left':(left-tw+w)+'px','top':(p.top+h)+'px','display':''});
          }
}

function getAllCitiesNav(input,alpha,result_id,pos_corner){
  var str='';
      alpha=alpha.toUpperCase();
          for(var i=65;i<=90;i++){
          var a=String.fromCharCode(i);
            if(alpha==a){
                str+="<span class='hot_cities_nav' style='color:red;font-weight:bold;'>"+a+"</span>";
                }else{
            str+="<span class='hot_cities_nav'  onclick=\"showmorectiy2('"+input+"','"+a+"',event,'"+result_id+"','"+pos_corner+"');event.cancelBubble = true;\"  onmouseover='this.style.color=\"blue\";'  onmouseout='this.style.color=\"#000\"'>"+a+"</span>";
                }
          }
          return str;

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getContent(letters){
	//alert(letters);
   var tmp_arr=new Array();
   var length=0;
   if(/^[a-z]/i.test(letters)){
	   for(var i=97;i<=122;i++){
		   var tmp=String.fromCharCode(i);
		   for(var tmp_key in cities[tmp]){
			   var tmp_item=cities[tmp][tmp_key];
			   var p=new RegExp('^'+letters,"i");
			   if(p.test(tmp_item.b)||p.test(tmp_item.d)){
				  tmp_arr.push('"'+tmp_item.b+'":"'+tmp_item.a+'"');
				  length++;
			   }
		   }
	   }
	   if(length==0) return {};
       else return eval('({'+tmp_arr.join(',')+'})');


   }else if(/^[\u4e00-\u9fa5]/.test(letters)){
	   for(var i=97;i<=122;i++){
		   var tmp=String.fromCharCode(i);
		   for(var tmp_key in cities[tmp]){
			   var tmp_item=cities[tmp][tmp_key];
			   var p=new RegExp('^'+letters,"i");
			   if(p.test(tmp_item.a)){
				  tmp_arr.push('"'+tmp_item.b+'":"'+tmp_item.a+'"');
				  length++;
			   }
		   }
	   }
	   if(length==0) return {};
       else return eval('({'+tmp_arr.join(',')+'})');

   }else{
	return CityList.Default_Cities;
   }
}

function getParam(parmName){
				var url= document.location.search;
				if(url!="undefined")
				{
						var arrParam= url.split("&");
						for(var i =0;i<arrParam.length;i++)
						{
								var item=arrParam[i];
								var loc=item.indexOf(parmName+"=");
								if(loc!=-1)
								{
										return item.replace(parmName+"=","").replace("?","");
										break;
								}
						}
				}
				return null;
}

////////////////////////////////////////////////start CityList//////////////////////////////////////////////////////////////////
CityList.init=function(){
	for(var i=0;i<arguments.length;i++){
		new CityList(arguments[i]);
	}
}
function CityList(input_id){
	if($('#'+input_id).length==0) return;
	this.inputControl=$('#'+input_id)[0];
	this.activeItem=null;
	this.activeItemCSS='optionSelected';
	this.firstItemID=null;
	this.lastItemID=null;
	this.doc_click_inited=false;
	this.citylist=null;
	var _self=this;

    $('#'+input_id).keyup(function(event){event.stopPropagation();_self.showList(event);});
	$('#'+input_id).click(function(event){event.stopPropagation();$(document).click();$(this).select();_self.showList(event);});
	$(document).keydown(function(event){_self.keyNavigate(event); });
	//$(document).resize(function() {_self.resizeWindow(); });
	window.onresize=function(){
		//_self.resizeWindow();
	   //alert(_self.activeItemCSS);
	}
    $(document).click(function(){_self.hide();})


}
CityList.Browser={isIE:navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')<0}
CityList.Default_Cities={"BeiJing2":"\u5317\u4eac","ShenZhen":"\u6df1\u5733","GuangZhou":"\u5e7f\u5dde","ChengDu":"\u6210\u90fd","ChongQing":"\u91cd\u5e86","Xian":"\u897f\u5b89","HangZhou":"\u676d\u5dde","WuHan":"\u6b66\u6c49","kunMing":"\u6606\u660e"};

CityList.prototype.showList=function(e)
	{

		//document.all.keyword.focus();
		if(e.keyCode==37 || e.keyCode==39){return;}//left,right key
		if(e.keyCode==13 || e.keyCode==9){return;}//enter,tab key
		if(e.keyCode==38 || e.keyCode==40){return;}//up,down key
		this.activeItem=null;

		var full_str=this.inputControl.value;

		if(/[^\da-zA-Z\u4e00-\u9fa5]/.test(full_str)){
			full_str=full_str.replace(/[^\da-zA-Z\u4e00-\u9fa5]/g,'');//只能输入拼音或汉字
			this.inputControl.value=full_str;
		}
		if(full_str.length>10){
		  	full_str=full_str.substr(0,10);
			this.inputControl.value=full_str;
		}
	//	if( ajax_optionDiv && ajax_optionDiv.style.display!='none') inputObj.blur();
		var id_list='citylist_'+this.inputControl.id;
		var id_iframe='cityiframe_'+this.inputControl.id;

		if($('#'+id_list).length==0){
			$('body').append('<div style="left:-200px;top:-200px;" class="citylist" id="'+id_list+'"></div><iframe class="citylist_iframe" id="'+id_iframe+'" style="border:0px;padding:0px;margin:0px;background:#fff;"></iframe>');
		}

		this.citylist=$('#'+id_list)[0];
		this.iframe=$('#'+id_iframe)[0];

		var list=$('#'+id_list)[0];
		var iframe=$('#'+id_iframe)[0];

		iframe.style.width = list.offsetWidth + 'px';
		iframe.style.height = list.offsetHeight + 'px';


		this.resizeWindow();
		this.citylist.onselectstart =function(){return false;};

		var param_letters=e.type=='focus'||e.type=='click'?'':this.inputControl.value;
		var content=this.getItems(param_letters);

		this.bindData(content);

}
CityList.prototype.bindData=function(options_info){
		var tmp_str='<div class=\'citylist_title\' >输入中文/拼音或↑↓选择</div>';
		var k=0;
		for(var p in options_info){
			//nav_items[p]=options_info[p];
		   	tmp='<div  id=\'plane_city'+k+'\'><span class="py">'+p+'</span><span class="py_city">'+options_info[p]+'</span></div>';
		   	tmp_str+=tmp;
		   	k++;
		}
		this.firstItemID='plane_city0';
		this.lastItemID='plane_city'+(k-1);
		$(this.citylist).html(tmp_str);
		this.iframe.style.width = this.citylist.offsetWidth + 'px';
		this.iframe.style.height = this.citylist.offsetHeight + 'px';
	    this.setItemStyle();
		this.show();


}
CityList.prototype.setItemStyle=function(){
	    if($('#'+this.citylist.id+' div').length-1>10){
		   $('#'+this.citylist.id).css('paddingRight','20px');
		}else{
		   $('#'+this.citylist.id).css('paddingRight','2px');
		}
		 var _self=this;

		$('#'+this.citylist.id+' div').each(function(i){
			//ajax_list_activeItem=null;
			  if(this.id=='option_title') return;
			  if($(this).hasClass('citylist_title')){
				  $(this).css({'cursor':'default'});
				  return;
			  }
			  $(this).mouseover(function(){
				$(this).addClass('optionSelected');
			  })
			  $(this).mouseout(function(){
				if(this!=_self.activeItem)
				  $(this).removeClass('optionSelected');
			  })
		     $(this).click(function(event){
				  event.stopPropagation();
				   _self.activeItem=this;
				  _self.setInputValue();
			  });//end click
			   /**/
		 })//end each
		 return false;
	}
CityList.prototype.keyNavigate=function(e)
	{
        if(e.keyCode!=38&&e.keyCode!=40&&e.keyCode!=13&&e.keyCode!=9){
		 // return;
		}
		if($('#citylist_'+this.inputControl.id).length==0) return;//只侦听当前控件的键盘事件
		if(document.all)e = event;
		if(!this.citylist)return;
		if(this.citylist.style.display=='none')return;
		//alert(this.activeItem&&this.activeItem.id);

		if(!this.activeItem ){
			this.activeItem=e.keyCode==38?$('#'+this.lastItemID)[0]:$('#'+this.firstItemID)[0];
			this.setActiveItemStyle();
			return;
		}
		var activeItem=this.activeItem;

		if(e.keyCode==38){	// Up arrow
		     if(activeItem&& $(activeItem).prev().hasClass('citylist_title')){//最后一个
				return;
			 }else{
				$(activeItem).removeClass(this.activeItemCSS);
				this.activeItem=$(activeItem).prev()[0];
				this.setActiveItemStyle();
			}

		}

		if(e.keyCode==40){	// Down arrow
				//$('lele:'+$(ajax_list_activeItem).html()+'  <br>').prependTo('body');
				//alert(activeItem.id);
				if($(activeItem).next().length==0)return;
				$(activeItem).removeClass(this.activeItemCSS);
				this.activeItem=$(activeItem).next()[0];
				this.setActiveItemStyle();
		}

		if(e.keyCode==13 || e.keyCode==9){	// Enter key or tab key
			  this.setInputValue();
		}
		return true;
	}



CityList.prototype.setInputValue=function(){
			var str=$(this.activeItem).find('.py_city').text();
		  	$(this.inputControl).val(str);
		    this.hide();

}

CityList.prototype.getItems=function(letters){
   var tmp_arr=new Array();
   var length=0;
   if(/^[a-z]/i.test(letters)){
	   for(var i=97;i<=122;i++){
		   var tmp=String.fromCharCode(i);
		   for(var tmp_key in cities[tmp]){
			   var tmp_item=cities[tmp][tmp_key];
			   var p=new RegExp('^'+letters,"i");
			   if(p.test(tmp_item.b)||p.test(tmp_item.c)||p.test(tmp_item.d)){
				  tmp_arr.push('"'+tmp_item.b+'":"'+tmp_item.a+'"');
				  length++;
			   }
		   }
	   }
	   if(length==0) return CityList.Default_Cities;
       else return eval('({'+tmp_arr.join(',')+'})');

   }else if(/^[\u4e00-\u9fa5]/.test(letters)){
	   for(var i=97;i<=122;i++){
		   var tmp=String.fromCharCode(i);
		   for(var tmp_key in cities[tmp]){
			   var tmp_item=cities[tmp][tmp_key];
			   var p=new RegExp('^'+letters,"i");
			   if(p.test(tmp_item.a)){
				  tmp_arr.push('"'+tmp_item.b+'":"'+tmp_item.a+'"');
				  length++;
			   }
		   }
	   }
	   if(length==0) return CityList.Default_Cities;
       else return eval('({'+tmp_arr.join(',')+'})');

   }else{
	return CityList.Default_Cities;
   }
}



CityList.prototype.hide=function(){
		//if(this.citylist)this.citylist.style.display='none';
		//if(this.iframe)this.iframe.style.display='none';
		if($('#citylist_'+this.inputControl.id).length>0) $('#citylist_'+this.inputControl.id).remove();
		if($('#cityiframe_'+this.inputControl.id).length>0) $('#cityiframe_'+this.inputControl.id).remove();
}
CityList.prototype.show=function(){
		if(this.citylist)this.citylist.style.display='';
		if(this.iframe)this.iframe.style.display='';
}

CityList.prototype.setActiveItemStyle=function(){
		if(this.activeItem){
			$(this.activeItem).addClass(this.activeItemCSS);

		 }else{
		 	$('#'+this.firstItemID).addClass(this.activeItemCSS);
		 	this.activeItem=$(this.firstItemID)[0];
		}

}


CityList.prototype.getPos=function(o){
		  var t = o.offsetTop;
		  var l = o.offsetLeft;
		  while((o = o.offsetParent) != null){
			t += o.offsetTop;
			l += o.offsetLeft;
		  }
		  return {top:t,left:l};
}
CityList.prototype.resizeWindow=function(){
	/**/
	    var list=this.citylist;
		list.style.top = this.getPos(this.inputControl).top + this.inputControl.offsetHeight + 'px';
		list.style.left = this.getPos(this.inputControl).left + 'px';
		this.iframe.style.left = list.style.left;
		this.iframe.style.top = list.style.top;
		/**/

}
////////////////////////////////////////////////end CityList//////////////////////////////////////////////////////////////////

function getCenter(obj){
var p={"left":0,"top":0};
  var _obj=obj;
while(obj){
    p.left+=obj.offsetLeft;
    p.top+=obj.offsetTop;
obj=obj.offsetParent;
}
  var x=p.left+_obj.offsetWidth/2;
  var y=p.top+_obj.offsetHeight/2;
  return {"x":x,"y":y};
}



/**
* 调用方法：onClick="showAllCities(this.id,'',event,null,'left');"
* 第一个参数是单击对象的id，第二个参数是当前的开始的字母，第三个是现场事件对象，第四个是需要赋值的div或者span,第五个是左上角定位或右上角定位
**/
var cities_index=new Array();
function findCityLetter(city){
	for(var oa in cities){
	   for(var i=0;i<cities[oa].length;i++){
		     if(city==cities[oa][i].a){
				return oa;
			 }
	   }
	}
	return "";
}
function showmorectiy2(input,alpha,e,result_id,pos_corner){
	 var e=e||window.event;
	 e.cancelBubble = true;
      $(document).click(function(){if($('#hot_cities_table').length>0) $('#hot_cities_table').remove();});
	  if($('#hot_cities_table').length>0) $('#hot_cities_table').remove();
	  var now_city='';

	   if((alpha.length==0) && typeof result_id!='undefined' && result_id!='null'){
		    now_city=$.trim($('#'+result_id).html());
		  for(var c in cities_index){
			 if(c==now_city){
			  	 alpha=cities_index[c];flag=true;
				 break;
			  }
		   }
		   if(!flag){
			  alpha=findCityLetter(v);
		   }
	    }else{
		   now_city=$.trim($('#'+input).val());
	    }


	  if(alpha.length==0 && $.trim($('#'+input).val()).length>0){
		   var v=$.trim($('#'+input).val());
		   now_city=v;
		  var flag=false;
		  for(var c in cities_index){
			if(c==v){
			  	 var alpha=cities_index[c];flag=true;
				 break;
			}
		  }
		  if(!flag){
			  var alpha=findCityLetter(v);
		  }
	  }
	  if(alpha.length==0){
		   var alpha='a';
	  }

          var tc=cities[alpha.toLowerCase()];
          var ts=new Array();
          ts.push('<table id="hot_cities_table" style="display:none;">');
		  ts.push('<tr><td class="title">请选择城市</td></tr>');
		  ts.push('<tr><td class="title_hotcities">&nbsp;&nbsp;<b>热门城市:</b>');
		  var h_c_a=new Array('深圳','北京','上海','广州','重庆','武汉','成都','西安');
		  for(var i=0;i<h_c_a.length;i++){
			 ts.push('<span onclick="setLastTab(\''+result_id+'\',\''+h_c_a[i]+'\');$(\'#hot_cities_table\').remove();">'+h_c_a[i]+'</span>');
		  }
		  ts.push('</td></tr><tr><td id="hot_cities_title">'+getAllCitiesNav(input,alpha,result_id,pos_corner)+'</td></tr>');
          ts.push('<tr><td id="hot_cities_content">');
          ts.push('<table id="hot_cities_list">');
          if(!tc){//如果没有城市记录
            ts.push('<tr rowspan="3"><td colspan="6" class="hot_cities_none">没有相关城市信息</td></tr></table>');
                  $('body').append(ts.join(''));
             setAllCitiesStyle(input,alpha,result_id,pos_corner)
                 return;
          }
          for(var i=0,r=0,j=tc.length;i<j;i++){//以某一个字母开头的城市展示出来
            var o=tc[i];
                if(i%6==0){//每行展示6个
                  ts.push('</tr><tr>');
                  r++;//table's row行数
                }
                ts.push('<td class="hotcity');
                if(o.a==now_city){
                  ts.push(' cur_city ');
                }
                ts.push('" onclick="assignCity(\''+input+'\',\''+o.a+'\',this,\''+alpha+'\',\''+result_id+'\');event.cancelBubble = true;">'+o.a+'</td>');

          }//end for
          if(i%6==1) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==2) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==3) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==4) ts.push('<td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          if(i%6==5) ts.push('<td >&nbsp;&nbsp;</td></tr>');

          if(r==1){
            ts.push('<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
            ts.push('<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          }else if(r==2){
            ts.push('<tr><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td><td>&nbsp;&nbsp;</td></tr>');
          }
          ts.push('</table>');
          ts.push('</td></tr></table>');
          $('body').append(ts.join(''));
          $('#hot_cities_table').click(function(){return false;})
          $('td.hotcity',$('#hot_cities_list')).hover(function(){$(this).addClass('over');},function(){$(this).removeClass('over');})
          setAllCitiesStyle(input,alpha,result_id,pos_corner)

}

function assignCity(input,city,td_obj,alpha,result_id){
    if($(td_obj).length>0){
		$('td.cur_city',$('#hot_cities_list')).removeClass('cur_city');
		$(td_obj).addClass('cur_city');
	}
    cities_index[$(td_obj).text()]=alpha;
	if(result_id!=undefined && result_id!='undefined' && result_id!='null'){
		if(typeof setLastTab=='function') setLastTab(result_id,city);
	}else{
		$('#'+input).val(city);
	}
     $('#hot_cities_table').remove();

}
function setAllCitiesStyle(input,alpha,result_id,pos_corner){
          getAllCitiesNav(input,alpha,result_id);
          var p=$('#'+input).offset();
          var h=$('#'+input)[0].offsetHeight;
          var w=$('#'+input)[0].offsetWidth;
          var left=p.left;
          var tw=$('#hot_cities_table').outerWidth()
          var bw=$('body').outerWidth();
		  if(pos_corner=='right'){
		     $('#hot_cities_table').css({'left':(left-tw+w)+'px','top':(p.top+h)+'px','display':''});
			return false;
		  }
		  if(pos_corner=='left'){
          $('#hot_cities_table').css({'left':p.left+'px','top':(p.top+h)+'px','display':''});
			return false;
		  }
          if((bw-left)>tw ){
          $('#hot_cities_table').css({'left':p.left+'px','top':(p.top+h)+'px','display':''});
          }else{
           $('#hot_cities_table').css({'left':(left-tw+w)+'px','top':(p.top+h)+'px','display':''});
          }
}

function getAllCitiesNav(input,alpha,result_id,pos_corner){
  var str='';
      alpha=alpha.toUpperCase();
          for(var i=65;i<=90;i++){
          var a=String.fromCharCode(i);
            if(alpha==a){
                str+="<span class='hot_cities_nav' style='color:red;font-weight:bold;'>"+a+"</span>";
                }else{
            str+="<span class='hot_cities_nav'  onclick=\"showmorectiy2('"+input+"','"+a+"',event,'"+result_id+"','"+pos_corner+"');event.cancelBubble = true;\"  onmouseover='this.style.color=\"blue\";'  onmouseout='this.style.color=\"#000\"'>"+a+"</span>";
                }
          }
          return str;

}

var Drag = {

    obj : null,

    init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
    {
        o.onmousedown    = Drag.start;

        o.hmode            = bSwapHorzRef ? false : true ;
        o.vmode            = bSwapVertRef ? false : true ;

        o.root = oRoot && oRoot != null ? oRoot : o ;

        if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
        if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
        if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
        if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

        o.minX    = typeof minX != 'undefined' ? minX : null;
        o.minY    = typeof minY != 'undefined' ? minY : null;
        o.maxX    = typeof maxX != 'undefined' ? maxX : null;
        o.maxY    = typeof maxY != 'undefined' ? maxY : null;

        o.xMapper = fXMapper ? fXMapper : null;
        o.yMapper = fYMapper ? fYMapper : null;

        o.root.onDragStart    = new Function();
        o.root.onDragEnd    = new Function();
        o.root.onDrag        = new Function();
    },

    start : function(e)
    {
        var o = Drag.obj = this;
        e = Drag.fixE(e);
        var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
        o.root.onDragStart(x, y);

        o.lastMouseX    = e.clientX;
        o.lastMouseY    = e.clientY;

        if (o.hmode) {
            if (o.minX != null)    o.minMouseX    = e.clientX - x + o.minX;
            if (o.maxX != null)    o.maxMouseX    = o.minMouseX + o.maxX - o.minX;
        } else {
            if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
            if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
        }

        if (o.vmode) {
            if (o.minY != null)    o.minMouseY    = e.clientY - y + o.minY;
            if (o.maxY != null)    o.maxMouseY    = o.minMouseY + o.maxY - o.minY;
        } else {
            if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
            if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
        }

        document.onmousemove    = Drag.drag;
        document.onmouseup        = Drag.end;

        return false;
    },

    drag : function(e)
    {
        e = Drag.fixE(e);
        var o = Drag.obj;

        var ey    = e.clientY;
        var ex    = e.clientX;
        var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
        var nx, ny;

        if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
        if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
        if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
        if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

        nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
        ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

        if (o.xMapper)        nx = o.xMapper(y)
        else if (o.yMapper)    ny = o.yMapper(x)

        Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
        Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
        Drag.obj.lastMouseX    = ex;
        Drag.obj.lastMouseY    = ey;

        Drag.obj.root.onDrag(nx, ny);
        return false;
    },

    end : function()
    {
        document.onmousemove = null;
        document.onmouseup   = null;
        Drag.obj.root.onDragEnd(    parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]),
                                    parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
        Drag.obj = null;
    },

    fixE : function(e)
    {
        if (typeof e == 'undefined') e = window.event;
        if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
        if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
        return e;
    }
};




////////////////////////////////////////////////////////////////
var KX = window.KX || {};
KX.Fp = KX.Fp || {};
$(document).click(function(){
						   if($('#CalFrame').length>0) $('#CalFrame').css('display','none');
						   if($('#morecitydiv').length>0) hidemorecitydiv();
					});
KX.Fp.change = function(id,num) {//{{{
    var name = document.getElementById(id);
    var span = name.getElementsByTagName("span");
    for(var i=0;i<span.length;i++){
        span[i].className = "";
        $("#"+id+"_ul_"+i).hide();
    }
    span[num].className = "checked";
    $("#"+id+"_ul_"+num).show();
}//}}}


KX.Fp.switchoption = function(obj){ //{{{
    if(obj.value == 1 ){
        $("#fcdate").hide();
        KX.Fp.jipiaotype = 1;
    }
    else{
        $("#fcdate").show();
        KX.Fp.jipiaotype = 2;
    }
}//}}}

KX.Fp.kxchange = function(id,num) {//{{{
    var name = document.getElementById(id);
    var span = name.getElementsByTagName("span");
    for(var i=0;i<span.length;i++){
        span[i].className = "sp"+i;
        document.getElementById(id+"_ul_"+i).style.display = "none";
    }
    span[num].className = "sp"+num+num;
    document.getElementById(id+"_ul_"+num).style.display = "block";
}//}}}

KX.Fp.parseDate = function(s) {//{{{
    var reg = new RegExp("[^0-9-]","");
    if(s.search(reg)>=0){
        return today;
    }
    var ss=s.split("-");
    if(ss.length!=3){
        return today;
    }
    if(isNaN(ss[0])||isNaN(ss[1])||isNaN(ss[2])){
        return today;
    }
    return new Date(parseFloat(ss[0]),parseFloat(ss[1])-1,parseFloat(ss[2]));
}//}}}

KX.Fp.formatDate = function(d) {//{{{
    var year = d.getFullYear();
    var month = d.getMonth() + 1;
    var day = d.getDate();
    return year+"-"+(month>=10 ? month : ("0" + month))+"-"+(day>=10 ? day : ("0" + day));
}//}}}

KX.cookie = {//{{{
    get: function(n) {
        var v = '',
        c = ' ' + document.cookie + ';',
        s = c.indexOf((' ' + n + '='));
        if (s >= 0) {
            s += n.length + 2;
            v = unescape(c.substring(s, c.indexOf(';', s)));
        }
        return v;
    },
    set: function(n, v) {
        var a = arguments,
        al = a.length;
        document.cookie = n + "=" + v + ((al > 2 && a[2] != "") ? ";expires=" + (typeof(a[2]) == "object" ? a[2].toGMTString() : (new Date(a[2] * 1000)).toGMTString()) : "") + ";path=" + ((al > 3 && a[3] != "") ? a[3] : "/") + ";domain=" + ((al > 4 && a[4] != "") ? a[4]:"kuxun.cn");
    },
    checksub: function(sCookie, s) {
        var aParts = sCookie.split('&'),
        nParts = aParts.length,
        aKeyVal;
        if (nParts == 1) {
            return sCookie.indexOf(s);
        } else {
            for (var i = 0; i < nParts; i++) {
                aKeyVal = aParts[i].split('=');
                if (aKeyVal[0] == s) {
                    return i;
                }
            }
        }
        return - 1;
    },
    getsub: function(n, s) {
        var sCookie = this.get(n);
        var nExists = this.checksub(sCookie, s);
        if (nExists > -1) {
            return sCookie.split('&')[nExists].split('=')[1];
        } else if (sCookie.indexOf(s) > 0) {
            return sCookie.split('=')[1];
        }
        return '';
    },
    setsub: function(n, s, v) {
        var sCookie = this.get(n),
        a = arguments,
        al = a.length;
        var aParts = sCookie.split('&');
        var nExists = this.checksub(sCookie, s);
        if (sCookie == '') {
            sNewVal = (s + '=' + v).toString();
        } else {
            if (nExists == -1) {
                nExists = aParts.length;
            }
            aParts[nExists] = s + '=' + v;
            sNewVal = aParts.join('&');
        }
        return this.set(n, sNewVal, (a[3] || ''), (a[4] || '/'), (a[5] || ''));
    }
}//}}}


KX.Fp.open_hrc = function() {//{{{
    var q_hrc = document.getElementById("q_hrc");
    if(q_hrc && q_hrc.checked){
        var open_url = "http://hotel.kuxun.cn/go_hrc_search.php?sid=4&city="+encodeURIComponent($('#city').val())+"&d1="+$('#i-startdate').val()+"&d2="+$('#i-enddate').val()+"&q="+encodeURIComponent($('#input03').val());
        var win = window.open(open_url, 'newwin','width=800,height=600,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes');
        win.blur();
    }

}//}}}

KX.Fp.onSubmitHotel = function() {//{{{
    if(KX.Fp.check()){
        KX.Fp.open_hrc();
        return true;
    }else{
        return false;
    }
}//}}}

function oncal(inp){inp.style.color="";if(inp.value == "选填") inp.value = "";}

function calcallback(str, target) {//{{{
    target.value = str;
    if(target.getAttribute("id") == "i-startdate") {
        var dateArr = str.split('-');
        var date1 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));
        dateArr = document.getElementById("i-enddate").value.split('-');
        var date2 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));
        if(date1.getTime() > date2.getTime()) {
            date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate() + 3);
            document.getElementById("i-enddate").value = addPrefixZero(date1.getFullYear()) + "-" + addPrefixZero(date1.getMonth() + 1) + "-" + addPrefixZero(date1.getDate());
        }
    }
}//}}}

function calcallbackdj(str, target) {//{{{
    target.value = str;
    if(target.getAttribute("id") == "Date1") {
        var dateArr = str.split('-');
        var date1 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));
        dateArr = document.getElementById("Date2").value.split('-');
        var date2 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));
        if(date1.getTime() > date2.getTime()) {
            date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate() + 3);
            document.getElementById("Date2").value = addPrefixZero(date1.getFullYear()) + "-" + addPrefixZero(date1.getMonth() + 1) + "-" + addPrefixZero(date1.getDate());
        }
    }
}//}}}

function calcallbackjp(str, target) {
    target.value = str;
    if(target.getAttribute("id") == "i-date") {
        var dateArr = str.split('-');
        var date1 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));

		 if(document.getElementById('T2') && document.getElementById('T2').checked){
				dateArr = document.getElementById("i-rdate").value.split('-');
				var date2 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));
				if(date1.getTime() > date2.getTime()) {
					date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate() + 3);
					document.getElementById("i-rdate").value = addPrefixZero(date1.getFullYear()) + "-" + addPrefixZero(date1.getMonth() + 1) + "-" + addPrefixZero(date1.getDate());
				}
		 }

       if(document.getElementById('T2') && document.getElementById('T2').checked && document.getElementById('i-rdate').value.length==0)
	      document.getElementById('i-rdate').click();

    }
}
function calcallbackjp2(str, target) {
    target.value = str;
    if(target.getAttribute("id") == "i-date2") {
        var dateArr = str.split('-');
        var date1 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));
        dateArr = document.getElementById("i-rdate2").value.split('-');
        var date2 = new Date(parseInt(dateArr[0], 10), parseInt(dateArr[1], 10) - 1, parseInt(dateArr[2], 10));
        if(date1.getTime() > date2.getTime()) {
            date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate() + 3);
            document.getElementById("i-rdate2").value = addPrefixZero(date1.getFullYear()) + "-" + addPrefixZero(date1.getMonth() + 1) + "-" + addPrefixZero(date1.getDate());
        }

       if( document.getElementById('i-rdate2').value.length==0)
	   document.getElementById('i-rdate2').click();

    }
}
function addPrefixZero(num) {//{{{
    if(parseInt(num, 10) < 10) {
        return "0" + num.toString();
    } else {
        return num.toString();
    }
}//}}}



KX.Fp.o_sub = function(t,q) {//{{{
    var EE = encodeURIComponent || escape;
    var g_url="";
    if(q.length == 0){
        return false;
    }
    q = EE(q);

    if( t[0].checked )
        g_url="http://sodujia.kuxun.cn/s_Sight-" + q + ".html";
    else if( t[1].checked )
        g_url="http://sodujia.kuxun.cn/s_TravelNotes-" + q + ".html";
    else if( t[2].checked )
        g_url="http://sodujia.kuxun.cn/s_Faq-" + q + ".html";
    else if( t[3].checked )
        g_url = "http://sodujia.kuxun.cn/s_PicInfo-" + q + ".html";
    if(g_url != "")
        document.location.href = g_url;
    //window.open(g_url,"_blank");
    return false;
}//}}}

KX.Fp.onSubmitTravel = function() {//{{{
    KX.Fp.o_sub(this.S, this.q.value);
    if(window.event){
        event.returnValue=false;
    }
    return false;
}//}}}

KX.Fp.piaoOnlySearchForDestOrTrainline = function() {//{{{
    var form = document.spiao;
    var to = form.to;
    var tid = form.trainid;
    var opt_str = "选填";
    function isContentKey(kc) {return kc == 8 || kc == 32 || kc > 48;}
    var keydown_oldto = to.onkeydown;
    to.onkeydown=function(e){
        if(!e && window.event) e=window.event;
        if(keydown_oldto) keydown_oldto.call(this,e);
        if(isContentKey(e.keyCode)&&tid.value) tid.value='';
    };
    var keydown_oldtid = tid.onkeydown;
    tid.onkeydown=function(e){
        if(!e && window.event) e=window.event;
        if(keydown_oldtid) keydown_oldtid.call(this,e);
        if(isContentKey(e.keyCode)&&to.value) to.value = '';
    };
    // grey out input when blur
    $("#to, #trainid, #input03").focus(function(){
        if($(this).val() != opt_str){
            $(this).css({color:'#000'});
        }else{
            $(this).val('');
        }
    }).blur(function(){
        if($(this).val() == ''){
            $(this).val(opt_str);
            $(this).css({color:'#666'});
        }else{
            $(this).css({color:'#000'});
        }
    });
}//}}}

function piaoSearch(s) { //{{{
	var q = s.q;
	var t = s.T;
	if (!q || !t) return false;
	if (t.value == 'TicketSale' && !q.value) {
		alert('目的站或车次不能为空')
		return false;
	}
	kxalog('id=search/' + t.value, s);
	return true;
} //}}}

// fill dp {{{
function filldp() {
	var d=new Date();
	var hour = d.getHours();
	var ndays = hour < 19 ? 9 : 10;
	var ms = d.getTime();

	var optstr = "";
	for (var i=1; i<=ndays; i++) {
		d.setTime(ms + i*24*3600*1000);
		var y = d.getFullYear();
		var m = d.getMonth() + 1;
		if (m<10) m = '0' + m;
		var da = d.getDate();
		if (da<10) da = '0' + da;
		var dstr = y + '-' + m + '-' + da;
		optstr += ['<option value = "', dstr, '">', dstr, '</option>'].join('');
	}

	$('#dp').html(optstr);
}// }}}

KX.Fp.validDate = function(qdate) {//{{{
    var d=new Date();
    var now=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
    var diff=KX.Fp.compareDate(now,qdate,"-");
    if(diff > 30 || diff < 0){
        return false;
    }
    return true;
}//}}}

KX.Fp.compareDate = function(first,second,sign) {//{{{
    var fArray = first.split(sign);

    var sArray = second.split(sign);
    var fDate = new Date(fArray[0],fArray[1],fArray[2]);
    var sDate = new Date(sArray[0],sArray[1],sArray[2]);

    var t = Math.abs(fDate.getTime()-sDate.getTime());

    var days = t/(1000*60*60*24);
    return days;
}//}}}

/* calendar*///{{{
KX.Fp.showCalendar = function(sImg,bOpenBound,sFld1,sFld2,sCallback,d1) {
	$(document).click();
	var fld1,fld2;
	KX.Fp.sImg=sImg;
	var cf=document.getElementById("CalFrame");
		cf.style.position='absolute';
	var wcf=window.frames.CalFrame;
	if(d1 != null){
		wcf.date1 = document.getElementById(d1).value;
	}else{
		wcf.date1 = null;
	}
	var oImg=document.getElementById(sImg);
	if(!oImg){alert("控制对象不存在！");return;}
	if(!sFld1){alert("输入控件未指定！");return;}
	fld1=document.getElementById(sFld1);
	if(!fld1){alert("输入控件不存在！");return;}
	if(fld1.tagName!="INPUT"||fld1.type!="text"){alert("输入控件类型错误！");return;}
	if(sFld2)
	{
		fld2=document.getElementById(sFld2);
		if(!fld2){alert("参考控件不存在！");return;}
		if(fld2.tagName!="INPUT"||fld2.type!="text"){alert("参考控件类型错误！");return;}
	}
	if(!wcf.bCalLoaded){alert("日历未成功装载！请刷新页面！");return;}
	if(cf.style.display=="block"){cf.style.display="none";return;}

	KX.Fp.setPosition();

	cf.style.display = "block";
	wcf.openbound=bOpenBound;
	wcf.fld1=fld1;
	wcf.fld2=fld2;
	wcf.callback=sCallback;
	wcf.initCalendar();
}
window.onresize=function(){
	KX.Fp.setPosition();
}
KX.Fp.setPosition=function(){
	var cf=document.getElementById("CalFrame");
	var sImg=KX.Fp.sImg;
	if(!sImg) return;
	var oImg=document.getElementById(sImg);
	var eT=0,eL=0,p=oImg;
	if(document.body.scrollTop!=0 || (document.documentElement.scrollTop==0 && document.documentElement.clientHeight==0))
	{
		var sT=document.body.scrollTop,sL=document.body.scrollLeft;
		var eH=oImg.clientHeight,eW=oImg.clientWidth;
		while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
		cf.style.top=((document.body.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height) + "px";
		cf.style.left=((document.body.clientWidth-(eL-sL)>=cf.width)?eL:eL-cf.width) + "px";
	}
	else
	{
		var sT=document.documentElement.scrollTop,sL=document.documentElement.scrollLeft;
		var eH=oImg.clientHeight,eW=oImg.clientWidth;
		while(p&&p.tagName!="BODY"){eT+=p.offsetTop;eL+=p.offsetLeft;p=p.offsetParent;}
		var ie = document.all;
		if(!ie){
		cf.style.top=((document.documentElement.clientHeight-(eT-sT)-eH>=cf.height)?eT+eH:eT-cf.height) + "px";
		cf.style.left=((document.documentElement.clientWidth-(eL-sL)>=cf.width)?eL:eL-cf.width) + "px";
		}else{
			var browser = navigator.appName;
			var b_version = navigator.appVersion;
			var version = b_version.split(";");
			var trim_Version = version[1].replace(/[ ]/g, "");
			if(browser == "Microsoft Internet Explorer" && trim_Version == "MSIE7.0") {
				cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + 4 + "px";
				cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width) - 4 + "px";
			} else if(browser == "Microsoft Internet Explorer" && trim_Version == "MSIE6.0") {
				cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + 4 +"px";
				cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width) - 4 + "px";
			}else{
				<!--添加修改 调整时间框的位置 ouyd -->
				cf.style.top = ((document.body.clientHeight - (eT - sT) - eH >= cf.height) ? eT + eH : eT - cf.height) + 4 + "px";
				cf.style.left = ((document.body.clientWidth - (eL - sL) >= cf.width) ? eL : eL + eW - cf.width) - 4 + "px";
			}
		}
	}
}
function hideCalendar()
{
	var cf=document.getElementById("CalFrame");
	cf.style.display="none";
}
/*}}}*/

KX.Fp.isEmpty = function(v) {
        return ((v == null) || (v.length == 0) || /^\s+$/.test(v));
};

KX.Fp.onSubmitXianlu3 = function(i,w) {

    var T = $("#T").val();
    var S = $.trim($("#searchWord").val());
    if (KX.Fp.isEmpty(S)) {
        $('#error').html('请输入关键字').css('color', '#FF6600');
        $('#searchWord').css('border', '1px solid #FF6600').focus().keyup(function() {
            if ($(this).val()) {
                $('#searchWord').css('border', '1px solid #8CB6E0');
                $('#error').html('').css('color', '#000');
            }
        });
        if(window.event){
            event.returnValue=false;
        }

        return false;
    }

    kxalog('id=home_search',3);

    document.location.href = 'http://dujia.kuxun.cn/s_' + T + '-' + encodeURIComponent(S) + '.html';
    if(window.event){
        event.returnValue=false;
    }
    return false;
};
KX.Fp.checkSubmit = function (i,n,w) {

    var FR = $.trim($('#From'+n).val());
    if (n == 2) {
        var D1 = $.trim($('#Date3').val());
        var D2 = $.trim($('#Date4').val());
    } else {
        var D1 = $.trim($('#Date1').val());
        var D2 = $.trim($('#Date2').val());
    }

    if (!FR) {
        $('#error'+n).html('请输入出发城市').css('color', '#FF6600');
        $('#From'+n).css('border', '1px solid #FF6600').focus().keyup(function() {
            if ($(this).val()) {
                $('#From'+n).css('border', '1px solid #8CB6E0');
                if (w == 'home') {
                    $('#error'+n).html('');
                } else {
                    $('#error'+n).html('出发城市').css('color', '#000');
                }
            }
        });
        return false;
    }

    var QU = $.trim($('#searchWord'+n).val());
    var URI = 'http://dujia.kuxun.cn/s_' + ($('#T'+n).val() == 'Fit' ? 'Fit_' : '') + EE(FR) + '-' + EE(QU);

    var queryString = new Array();

    if (D1 && D1 != Mj.kDDS) {
        queryString.push('Date1=' + D1);
    }
    if (D2 && D2 != Mj.kDDS) {
        queryString.push('Date2=' + D2);
    }

    var CAT = $.trim($('#dropfeature1').val());
    if (CAT && CAT != Mj.kRY) {
        queryString.push('Cat7=' + EE(CAT));
    }

    var OEM = $.trim($('#OEM'+n).val());
    var FID = $.trim($('#fromid'+n).val());
    if (OEM) {
        queryString.push('OEM=' + OEM);
    }
    if (FID) {
        queryString.push('fromid=' + FID);
    }

    if (typeof(kxalog) == "function" && typeof(i) != "object") {
        kxalog('id=' + PAGETYPE + '_search/' + w, i);
    }

    var Q = queryString.join('&');
    window.location.href = URI + (Q ? '?' + Q : '');
    return false;
};
/* -( Bootstrap )--------------------------------------------- */
// This is where everything explictly initialized and runs, put
// implicityly-running non-definition code here so we can
// keep track of what's going on.

/* -( End )---------------------------------------------------- */
/*{{{
Modeline
vim:ft=javascript
vim:et sta sw=4
vim600:fdm=marker fdl=0 fdc=0
}}}*/



var MaskBox={cur_zIndex:10};
MaskBox.init=function(config_info){
        var box_id=config_info.box_id;
        var drag_id=config_info.drag_id||'';
        var close_id=config_info.close_id||'';

		var box_pos=config_info.box_pos||null;
		var box_pos_by=config_info.box_pos_by||'left';

		var offsetY=config_info.offsetY||0;
		var offsetX=config_info.offsetX||0;
		//var enableDrag=config_info.enableDrag||true;
		var autoScroll=typeof(config_info.autoScroll)=='boolean'?config_info.autoScroll:false;
		var mask_min=typeof(config_info.mask_min)=='boolean'?config_info.mask_min:false;

		MaskBox.cur_zIndex=config_info.zIndex||MaskBox.cur_zIndex;

		var mask_color=config_info.mask_color||'#444444';
		var mask_opacity=config_info.mask_opacity||0;
		if(mask_opacity>1) mask_opacity=1;
		if(!box_id){
			alert('配置错误');return;
		}
        var pos_top=config_info.pos_top||null;
        var doc_close=typeof(config_info.doc_close)=='boolean'?config_info.doc_close:true;
          var zindex=MaskBox.cur_zIndex;
          var flag=false;
                  if($('iframe[id^=frm_'+box_id+'_]').length>0){
                     flag=true;
                     var tmp_frm=$('iframe[id^=frm_'+box_id+'_]').eq(0);
                         var arr=tmp_frm.attr('id').split('_');
                         var tmp_zindex=arr[arr.length-1];//当前的zindex
                  }
                  if(flag){
                     var zindex=MaskBox.cur_zIndex=MaskBox.cur_zIndex+3;
                         var frmId='frm_'+box_id+'_'+tmp_zindex;
                         var overlayId='overlay_'+tmp_zindex;
                  }else{
                     var zindex=MaskBox.cur_zIndex=MaskBox.cur_zIndex+3;
                         var frmId='frm_'+box_id+'_'+zindex;
                         var overlayId='overlay_'+zindex;
                    $("body").append("<iframe id='"+frmId+"'></iframe><div id='"+overlayId+"'></div>");
                  }

     var de = document.documentElement;
        var w = (de&&de.clientWidth) ||window.innerWidth || self.innerWidth ||  document.body.clientWidth;
        var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;

		if(box_pos){
			if(box_pos_by=='right'){
				var box_left=$(box_pos).offset().left-($('#'+box_id).outerWidth()-$(box_pos).outerWidth());
			}else if(box_pos_by=='center'){
				var box_left=(w-$('#'+box_id).outerWidth())/2;
			}else{
				var box_left=$(box_pos).offset().left;
			}
			var box_top=$(box_pos).offset().top+$(box_pos).outerHeight();
		}else{
			var box_left=(w-$('#'+box_id).outerWidth())/2;
			if(pos_top){
				var box_top=(pos_top+'').replace(/[^\d]/g,'');
			}else if((h-$('#'+box_id).outerHeight())>0){
					var box_top=(h-$('#'+box_id).outerHeight())/2;
			}else{
				var box_top=0;
			}

		}

		box_top=parseInt(box_top)+parseInt(offsetY);
		box_left=parseInt(box_left)+parseInt(offsetX);
   /*设置遮罩层*/
       if (window.innerHeight && window.scrollMaxY) {
         yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.documentElement && document.documentElement.scrollHeight){
         yScroll = document.documentElement.scrollHeight;
        } else {
          yScroll = document.body.offsetHeight;
        }
        var max_h=h>yScroll?h:yScroll;
        var max_w=w;
        var yScrolltop;

        if (self.pageYOffset) {
                yScrolltop = self.pageYOffset;
        } else if (document.documentElement && document.documentElement.scrollTop){         // Explorer 6 Strict
                yScrolltop = document.documentElement.scrollTop;
        } else if (document.body) {// all other Explorers
                yScrolltop = document.body.scrollTop;
        }

		/**
		if(autoScroll){
			box_top=pos_top?pos_top:(box_top+yScrolltop);
		}else{
			 box_top=pos_top?pos_top:box_top;
		}
		/**/
      //

   $("#"+overlayId).css({'height':max_h +'px','width':max_w+'px','display':'','border':'none','position':'absolute','left':'0px','top':'0px','z-index':zindex+1,'opacity':mask_opacity,'background-color':mask_color});

   $("#"+frmId).css({'display':'','border':'0px solid red','position':'absolute','opacity':'0','z-index':zindex});

   if(mask_min){
   	var mask_min_w=$('#'+box_id).outerWidth();
   	var mask_min_h=$('#'+box_id).outerHeight();
	   $("#"+frmId).css({'height':mask_min_h +'px','width':mask_min_w+'px','left':box_left+'px','top':box_top+'px'});
   }else{
	   $("#"+frmId).css({'height':max_h +'px','width':max_w+'px','left':'0px','top':'0px'});
   }

   if(typeof box_id!='undefined' && box_id.length>0){
    $('#'+box_id).css({'display':'','left':box_left+'px','top':box_top+'px','z-index':zindex+2});
   }
  if(close_id) $('#'+close_id).click(function(){  $('#'+box_id+',#'+overlayId+',#'+frmId).css('display','none');  });
  if(drag_id) $('#'+drag_id).css('cursor','move');

   if(drag_id){
      $('#'+drag_id).css('cursor','move');
      Drag.init($('#'+drag_id)[0],$('#'+box_id)[0]);
   }
 // $("#"+overlayId).click(function(){alert('click222222222');  });
   if(doc_close){
	   $("#"+overlayId).click(function(){$('#'+close_id).click();  });
	   //$(document).click(function(){alert('ddd');});
   }

}



var TFL = typeof(TFL) == "object" ? TFL : {};
function PageBar(){
    this.pageInfo = {
        recordcount : 0,
        positions : [],
        page : 1,
        returnPage : 1, //add new
        pageSize : 8,
        returnPages : 0, //add new
        noRecordcount : false, //add new
        hasNext : false, //add new
        offset : 2,
        radius : 3,
        handler:null,
        args:[],
        jumpSize:10,
        isShowJumper:true,
        isShowPages:true,
        currentPage : 0,
        virtualPage : 0, //add new
        totalPageSize : 0,
        viewSize : 0,
        defSize : 0,
		isDrawPageBar:true,
		page_str:'',
		start_cursor:0,
		end_cursor:0,
        namespace : "TFL.PageBar"
    };
}
PageBar.prototype = {
    $:function(id){
        return document.getElementById(id);
    },
    setPageInfo : function(pageInfo){
        this.pageInfo.recordcount = pageInfo.recordcount || 0;
        this.pageInfo.positions = pageInfo.positions || [];
        this.pageInfo.pageSize  = pageInfo.pageSize || this.pageInfo.pageSize;
        this.pageInfo.jumpSize = pageInfo.jumpSize || this.pageInfo.jumpSize;
        this.pageInfo.returnPages = typeof(pageInfo.returnPages) == "number" ? pageInfo.returnPages : this.pageInfo.returnPages;
        this.pageInfo.noRecordcount = typeof(pageInfo.noRecordcount) == "boolean" ? pageInfo.noRecordcount : this.pageInfo.noRecordcount;
        this.pageInfo.hasNext = typeof(pageInfo.hasNext) == "boolean" ? pageInfo.hasNext : this.pageInfo.hasNext;
        this.pageInfo.isShowJumper = typeof(pageInfo.isShowJumper) == "boolean" ? pageInfo.isShowJumper : this.pageInfo.isShowJumper;
        this.pageInfo.isShowPages = typeof(pageInfo.isShowPages) == "boolean" ? pageInfo.isShowPages : this.pageInfo.isShowPages;
        this.pageInfo.offset  = typeof(pageInfo.offset) == "number" ? pageInfo.offset : this.pageInfo.offset;
        this.pageInfo.radius  = typeof(pageInfo.radius) == "number" ? pageInfo.radius : this.pageInfo.radius;
        this.pageInfo.namespace = pageInfo.namespace ? pageInfo.namespace : this.pageInfo.namespace;
        this.pageInfo.handler  = pageInfo.handler || null;
        this.pageInfo.args  = pageInfo.args || [];
        this.pageInfo.page = pageInfo.page || 1;
        this.pageInfo.returnPage = pageInfo.returnPage || 1;
        this.pageInfo.currentPage = Math.max(this.pageInfo.page - 1, 0);
        this.pageInfo.virtualPage = Math.max(this.pageInfo.returnPage - 1, 0) * this.pageInfo.returnPages + this.pageInfo.currentPage;
        this.pageInfo.totalPageSize = Math.ceil(this.pageInfo.recordcount / this.pageInfo.pageSize);
        this.pageInfo.viewSize = this.pageInfo.radius * 2 + 1;
        this.pageInfo.defSize = 9;/*this.pageInfo.viewSize + this.pageInfo.offset;*/

		this.pageInfo.start_cursor=this.pageInfo.currentPage*this.pageInfo.pageSize;
		this.pageInfo.end_cursor=this.pageInfo.start_cursor+this.pageInfo.pageSize;
        this.pageInfo.isDrawPageBar =typeof(pageInfo.isDrawPageBar)=="boolean"?pageInfo.isDrawPageBar:this.pageInfo.isDrawPageBar;/*this.pageInfo.viewSize + this.pageInfo.offset;*/
    },
    getPageInfo : function(){
        return this.pageInfo;
    },
    getPageItem : function(page){
        //var currentPage = this.pageInfo.noRecordcount ? this.pageInfo.virtualPage : this.pageInfo.currentPage;
        var currentPage = this.pageInfo.currentPage;
        var actualPage = this.pageInfo.noRecordcount ? Math.max(this.pageInfo.returnPage - 1, 0) * this.pageInfo.returnPages + page : page;
        var item = '<a${className} href="javascript:${link};">${page}</a>';
        item = item.replace("${page}", (actualPage + 1));
        if(page != currentPage){
            item = item.replace("${link}", this.pageInfo.namespace + ".turnPage("+page+", true, false)");
            item = item.replace("${className}", "");
        }else{
            item = item.replace("${link}", "void(0)");
            item = item.replace("${className}", " class=\"selected\"");
        }
        return item;
    },
    getPageItems : function(type){
        var totalPageSize = this.pageInfo.totalPageSize;
        var currentPage = this.pageInfo.currentPage;
        var offset = this.pageInfo.offset;
        var radius = this.pageInfo.radius;
        var viewSize = this.pageInfo.viewSize;
        var defSize = this.pageInfo.defSize;
        var ellipsis = this.pageInfo.noRecordcount ? '' : '<em class="ellipsis">…</em>';
        var tmp = "";
        var items = "";
        if(!this.pageInfo.noRecordcount){
            if(0 == type){ /* 1~9*/
                for(var i = 0; i < totalPageSize; i++){
                    items += this.getPageItem(i);
                }
            }else{ /* >9*/
                var tmpSize = radius < 3 ? viewSize + offset : viewSize;
                if(currentPage >= tmpSize - 1){
                    for(var i = 0; i < offset; i++){
                        items += this.getPageItem(i);
                    }
                    items += ellipsis;
                    if(totalPageSize - defSize - 1 > 0 && totalPageSize - defSize - 1 <= offset){
                        for(var i = totalPageSize - defSize + offset; i < totalPageSize; i++){
                            items += this.getPageItem(i);
                        }
                    }else{
                        if(totalPageSize - currentPage < tmpSize){
                            for(var i = totalPageSize - tmpSize; i < totalPageSize; i++){
                                items += this.getPageItem(i);
                            }
                        }else{
                            for(var i = currentPage - radius; i <= currentPage + radius; i++){
                                items += this.getPageItem(i);
                            }
                            items += ellipsis;
                            for(var i = totalPageSize - offset ; i < totalPageSize; i++){
                                items += this.getPageItem(i);
                            }
                        }
                    }
                }else{
                    for(var i = 0; i < tmpSize; i++){
                        items += this.getPageItem(i);
                    }
                    items += ellipsis;
                    for(var i = totalPageSize - offset ; i < totalPageSize; i++){
                        items += this.getPageItem(i);
                    }
                }
            }
        }else{
            for(var i = 0; i < totalPageSize && i < this.pageInfo.returnPages; i++){
                //items += this.getPageItem(Math.max(this.pageInfo.returnPage - 1, 0) * this.pageInfo.returnPages + i);
                items += this.getPageItem(i);
            }
        }
        return items;
    },
    checkValue : function(isJump){
        var pattern = /^\d+$/;
        var input = this.$("_pagebar_input");
        var v = 1;
        if(null != input){
            v = input.value;
            if(!pattern.test(v)){
                this.$("_pagebar_input").value = 1;
                v = 1;
            }
            v = parseInt(v, 10);
            if(v < 1){
                v = 1;
            }else if(v > this.pageInfo.totalPageSize){
                v = this.pageInfo.totalPageSize;
            }
            v = v - 1;
            if(v != this.pageInfo.currentPage && isJump){
                this.turnPage(v, true, false);
            }
        }
    },
    getJumpInput : function(){
        var str = '<label>第<input type="text" value="'+ (this.pageInfo.currentPage + 1) +'" id="_pagebar_input" onkeyup="'+ this.pageInfo.namespace + '.checkValue(false)">页 <button onclick="'+ this.pageInfo.namespace + '.checkValue(true)">跳转</button><label>';
        return str;
    },
    turnPage : function(offset, isPage, isInit){
        var isCurrentPage = false;
        var isLTZero = false;
        if(isPage){
            isCurrentPage = (offset == this.pageInfo.currentPage);
            this.pageInfo.currentPage = offset;
        }else{
            isCurrentPage = false;
            this.pageInfo.currentPage += offset;
        }
        var currentPage = this.pageInfo.currentPage;
        var totalPageSize = this.pageInfo.totalPageSize;
        if(currentPage < 0){
            isLTZero = true;
            this.pageInfo.currentPage = 0;
        }
        if(currentPage > totalPageSize - 1){
            this.pageInfo.currentPage = totalPageSize - 1;
        }
        if(this.pageInfo.noRecordcount){
            this.pageInfo.virtualPage = Math.max(this.pageInfo.returnPage - 1, 0) * this.pageInfo.returnPages + this.pageInfo.currentPage;
        }
        this.draw();
        if(null != this.pageInfo.handler && (!isCurrentPage || isInit)){
            if(this.pageInfo.noRecordcount && isLTZero){
                this.pageInfo.currentPage -= 1;
            }
            this.pageInfo.handler.apply(this.pageInfo.handler, this.pageInfo.args);
        }
    },
    getPageBar : function(){
        var totalPageSize = this.pageInfo.totalPageSize;
        var currentPage = this.pageInfo.currentPage;
        if(totalPageSize > 1 || (this.pageInfo.noRecordcount && totalPageSize == 1 && this.pageInfo.virtualPage > 0)){
            var str = '<div class="page-bar">';
            str += this.pageInfo.isShowPages ? '<span>'+(currentPage+1)+'/'+totalPageSize+'页</span>' : "";
            if(currentPage > 0 || this.pageInfo.noRecordcount){
                if(0 == currentPage && this.pageInfo.noRecordcount && 0 == this.pageInfo.virtualPage){
                    str += '<a class="text dis" href="javascript://">上一页</a>';
                }else{
                    str += '<a class="text" href="javascript:'+ this.pageInfo.namespace + '.turnPage(-1, false, false);">上一页</a>';
                }
            }
            if(totalPageSize <= this.pageInfo.defSize){
                str += this.getPageItems(0);
            }else{
                str += this.getPageItems(1);
            }
            if(currentPage < totalPageSize - 1 || this.pageInfo.noRecordcount){
                if((currentPage == totalPageSize - 1 || currentPage == this.pageInfo.returnPages - 1) && !this.pageInfo.hasNext && this.pageInfo.noRecordcount){
                    str += '<a class="text dis" href="javascript://">下一页</a>';
                }else{
                    str += '<a class="text" href="javascript:'+ this.pageInfo.namespace + '.turnPage(1, false, false);">下一页</a>';
                }
            }
            if(totalPageSize > this.pageInfo.jumpSize && this.pageInfo.isShowJumper){
                str += this.getJumpInput();
            }
            str += "</div>";
			if(!this.pageInfo.isDrawPageBar){
			  this.pageInfo.page_str=str;
			}
            return str;
        }else{
            return "";
        }
    },
    draw : function(){
        var positions = this.pageInfo.positions;
        var len = positions.length;
        var pos = null;

		this.pageInfo.start_cursor=this.pageInfo.currentPage*this.pageInfo.pageSize;
		this.pageInfo.end_cursor=this.pageInfo.start_cursor+this.pageInfo.pageSize;

        var pageBar = this.getPageBar();

		if(!this.pageInfo.isDrawPageBar){
			//alert(this.pageInfo.page_str);
			//this.page_str=pageBar;
			return;
		}
        for(var i = 0; i < len; i++){
            pos = this.$(positions[i]);
            if(pos){
                pos.innerHTML = pageBar;
            }
        }
    },
    init : function(pageInfo){
        this.setPageInfo(pageInfo);
        this.turnPage(this.pageInfo.currentPage, true, true);
    }
};
TFL.PageBar = new PageBar();


var TFL = TFL || {};

TFL.timer = (
function()
{
	var _re = /\-|\_|\.|\*|\/|\\|[\u4e00-\u9fa5]/g;
	var _splitStr = "-";//显示分隔符
	var _this =
	{
		obj : null,
		curControl : null,
		curIndex : 0,
		year : new Date().getFullYear(),//定义年的变量的初始值
		month : new Date().getMonth() + 1,//定义月的变量的初始值
		days : new Array(37),//定义写日期的数组
		speMonth : [31,28,31,30,31,30,31,31,30,31,30,31]//定义每个月的最大天数
	};
	var _$ = function(o)
	{
		return typeof o == "object" ? o : document.getElementById(o);
	};
	var _isIE = (document.all) ? true : false;
    var _isIE6 = _isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
	var refers={};
	var hideToday=false;

	/**
	 * 绑定文本框
	 */
	var _bindControl = function(obj)
	{

		/**
		 * obj属性
		 * 1.showControl(true || false) 是否显示控件
		 * 2.parent 控件显示的容器
		 * 3.items 控件id名集合,如:["input1","input2"]
		 * 4.rules 控件显示规则
		 * 5.today 今天链接{"hidden" : 隐藏，默认显示}
		 * 6.mask {true : 显示iframe解决ie6下select问题，默认不显示}
		 * 7.evn 数组变量[]，日期点击时触发
		 * 8.autoShow 是否自动显示下一个控件
         * 9.offsetX 与当前对象的水平偏移值    add by carlli
         * 10. offsetY 与当前对象的垂直偏移值  add by carlli

		 if(!obj.rules.from){
			 obj.rules.from=_getToday().replace(/-/g,"/");
			//obj.rules.from="2009/12/18";
		 }
		 */
		var _o = _this.obj = obj;
		if(_o.items.length>1){
		  	refers[_o.items[1]]=_o.items[0];
		}
		if(_o.hideToday){
			hideToday=true;
		}
		if(_o.showControl && _o.parent)//满足这两个条件则自动画控件
		{
			for(var i = 0; i < _o.items.length; i++)
			{
				var _i = document.createElement("input");
				_i.id = _o.items[i];
				_i.index = i;
				_i.style.imeMode = "disabled"
				_bindClickEvt(_i);
				_$(_o.parent).appendChild(_i);
				if(i < _o.items.length - 1)
				{
					var _span = document.createElement("span");
					_span.innerHTML = " 至 ";
					_$(_o.parent).appendChild(_span);
				}
			}
		}
		else
		{
			for(var i = 0; i < _o.items.length; i++)
			{
				_$(_o.items[i]).index = i;
				_$(_o.items[i]).style.imeMode = "disabled"
				_bindClickEvt(_$(_o.items[i]));
			}
		}
	};
	var _bindClickEvt = function(ctl)
	{

		if(document.all)
		{
			ctl.attachEvent(
				"onfocus",
				function(e)
				{
					_this.curControl = ctl;
					_this.curIndex = ctl.index;
					_showTimer();
					_clearEvent(e);
				}
			);
		}
		else
		{
			ctl.addEventListener(
				"focus",
				function(e)
				{
					_this.curControl = ctl;
					_this.curIndex = ctl.index;
					_showTimer();
					_clearEvent(e);
				},false
			);
		}
		ctl.onmousedown = _clearEvent;
	};
	var _getToday = function()
	{
		var today=new Date();
		var y=today.getFullYear();
		var m=today.getMonth()+1;
		if(m.toString().length==1){
		  m='0'+m;
		}
		var d=today.getDate();
		if(d.toString().length==1){
		  d='0'+d;
		}
		return y + _splitStr + m + _splitStr +d;
	};
	/**
	 * 显示日期控件
	 */
	var _showTimer = function()
	{
		if(!_$("dvTimerContainer")) return false;
		//document.body.onclick=function(){alert('hi');};
		var _control = _this.curControl;
		if(_this.obj.today && _this.obj.today == "hidden")
		{
			_$("todayDate").style.display = "none";
		}
		else
		{
			_$("todayDate").style.display = "";
		}
		if(typeof(_this.obj.rules) == "object")
		{
			if(_this.obj.rules.from && _this.curIndex == 0)
			{
				_this.year = parseInt(_this.obj.rules.from.split(_re)[0],10);
				_this.month = parseInt(_this.obj.rules.from.split(_re)[1],10);
			}
			if(!_this.obj.rules.end) _this.obj.rules.end = _getToday();
		}
		if(timeFormat(_control.value))//如果控件内容符合日期格式则自动定位到当前年月
		{
			_this.year = parseInt(_control.value.split(_re)[0],10);
			_this.month = parseInt(_control.value.split(_re)[1],10);
		}

		_initYearList(_this.year);
	  	_initMonthList(_this.month);
	  	_initDate(_this.year,_this.month);
	  	var _controlStyle  = _$("dvTimerContainer").style;
	  	var _top = _control.offsetTop;     //TT控件的定位点高
	  	var _height = _control.clientHeight;  //TT控件本身的高
	  	var _left = _control.offsetLeft;    //TT控件的定位点宽
	  	var _type = _control.type;          //TT控件的类型
	  	while (_control = _control.offsetParent){_top+=_control.offsetTop; _left += _control.offsetLeft;}


		if(typeof _this.obj.zIndex == 'number'){
			_controlStyle.zIndex=_this.obj.zIndex;
		}
	 	if(typeof(_this.obj.offsetY) == "number"){
            _controlStyle.top = (_top + _this.obj.offsetY) + "px";
        }else{
            _controlStyle.top = (_type=="image")? _top+_height : _top + _height + 5 + "px";
        }
        if(typeof(_this.obj.offsetX) == "number"){
            _controlStyle.left = (_left + _this.obj.offsetX) + "px";
        }else{
	 	    _controlStyle.left = _left + "px";
        }
	  	_controlStyle.display = "";
	};
	/**
	 * 将日前赋值给当前文本框，当有下一个文本框时则自动移动到下一个文本框，否则隐藏文本框
	 */
	var _setTime = function()
	{
		if(typeof _this.obj.callback =='function'){//是否有回调函数
			 _this.obj.callback(_this.curControl);
		}else if(typeof global_select_time_callback =='function'){//是否有回调函数
			 global_select_time_callback(_this.curControl);
		}
		var tmon = Number(_this.month);
		tmon = parseInt(tmon) < 10 ? "0"+tmon : tmon;
		_this.curControl.value = _this.year + _splitStr + tmon + _splitStr;

		if(parseInt(this.index,10)>=10){
			_this.curControl.value+=this.index;
		}else{
			_this.curControl.value+='0'+this.index;
		}
		if(typeof global_select_time_end_callback=='function'){
		  global_select_time_end_callback(_this.curControl);
		}
		if(_this.obj.evn && typeof(_this.obj.evn[_this.curIndex]) == "function")
		{
			_this.obj.evn[_this.curIndex].call(null); //触发点击事件
		}
		if(_this.curIndex < _this.obj.items.length - 1)
		{
			if(typeof(_this.obj.autoShow) != "undefined" && _this.obj.autoShow == false)
			{
				_$("dvTimerContainer").style.display = "none";
				return;
			}
			_this.curIndex += 1;
			_this.curControl = _$(_this.obj.items[_this.curIndex]);
			_showTimer();
		}
		else
		{
			_$("dvTimerContainer").style.display = "none";
		}

	};
	/**
	 * 初始化月份下拉
	 */
	var _initMonthList = function(m)
	{
		var m = m || new Date().getMonth() + 1;
		var _select = document.createElement("select");
		_select.onchange = function()
		{
			_this.month = this.value;
			_initDate(_this.year,_this.month);
		};
	 	for (var i = 1; i < 13; i++)
	 	{
	 		var _opt = document.createElement("option");
	    	if(i == m)
	       	{
	       		_opt.value = i;
	       		_opt.selected = true;
	       		_opt.innerHTML = _getMonCN(i) + "月";
	       	}
	    	else
	    	{
	    		_opt.value = i;
	       		_opt.innerHTML = _getMonCN(i) + "月";
	    	}
	    	_select.appendChild(_opt);
	  	}
	  	_$("snTimerMonthList").innerHTML = "";
	  	_$("snTimerMonthList").appendChild(_select);
	};
	var _getMonCN = function(m)
	{
		var _rtn = "";
		var _list = ["一","二","三","四","五","六","七","八","九","十","十一","十二"];
		for(var i = 1; i < _list.length + 1; i++)
		{
			if(m == i)
			{
				_rtn = _list[i - 1];
				break;
			}
		}
		return _rtn;
	};
	/**
	 * 初始化年份下拉
	 */
	var _initYearList = function(y)
	{
		var m = y || new Date().getFullYear();
	    if (m < 1000 || m > 9999) {alert("年份值不在 1000 到 9999 之间！");return;}
	  	var n = m - 10;
	  	if (n < 1000) n = 1000;
	  	if (n + 25 > 9999) n = 9974;

	  	var x = n;
	  	var y = n + 25;

	  	var _select = document.createElement("select");
	  	_select.onchange = function()
		{
			_this.year = this.value;
			_initDate(_this.year,_this.month);
		};
		if(_this.obj.rules)
	  	{
	  		if(_this.obj.rules.from) x = parseInt(_this.obj.rules.from,10);
			if(_this.obj.rules.end) y = parseInt(_this.obj.rules.end,10);
	  	}
	  	for (var i = x; i <= y; i++)
		{
		  	var _opt = document.createElement("option");
		    if(i == m)
		    {
		    	_opt.value = i;
		    	_opt.selected = true;
		    	_opt.innerHTML = i;
		    }
		    else
		    {
		    	_opt.value = i;
		       	_opt.innerHTML = i;
		    }
		    _select.appendChild(_opt);
		 }
	  	_$("snTimerYearList").innerHTML = "";
	  	_$("snTimerYearList").appendChild(_select);
	};
	/**
	 * 判断是否闰年
	 */
	var _isLeapYear = function(y)
	{
		if(0 == y % 4 && ((y % 100 != 0) || (y % 400 == 0)))
			return true;
		else
			return false;
	};
	/**
	 * 取得当月天数
	 */
	var _getMonDays = function(y,m)
	{
		var c = _this.speMonth[m - 1];
		if((m == 2) && _isLeapYear(y)) c++;
		return c;
	};
	/**
	 * 清除冒泡事件
	 */
	var _clearEvent = function(evt)
	{
		var e = (evt) ? evt : window.event;
		if (window.event)
		{
			e.cancelBubble=true;
		}
		else
		{
			e.stopPropagation();
		}
	};
	/**
	 * 初始化日期
	 */
	var _initDate = function(yy,mm)
	{

		for(var i = 0; i < 37; i++){_this.days[i] = ""};  //将显示框的内容全部清空
	  	var day1 = 1,firstday = new Date(yy,mm-1,1).getDay();  //某月第一天的星期几
	 	for(var i = firstday; day1 < _getMonDays(yy,mm)+1; i++){_this.days[i]=day1;day1++;}
		var _last =
		{
			control : null,
			year : "",
			month : "",
			day : ""
		};
		//alert(_last.control);


		if(_this.obj.items.length > 1)
		{
			if(_this.curIndex > 0)
			{
				//_last.control = _this.obj.items[_this.curIndex - 1];
				_last.control = refers[_this.curControl.id];
				//alert('f');
				_last.year = _$(_last.control).value.split(_re)[0];
				_last.month = _$(_last.control).value.split(_re)[1];

				_last.day = _$(_last.control).value.split(_re)[2];
			}
		}
		if( _$(_last.control)){
			var t=document.getElementById(_last.control).value;
		 // alert("thiscontral    "+_this.curControl.id+"  referer control:"+refers[_this.curControl.id]+"  lastcontrol:"+_last.control+"  "+ _$(_last.control).value);
		}
	  	for(var i = 0; i < 37; i++)
	  	{
	  		var da =_$("timerItem" + i);//书写新的一个月的日期星期排列
	  		var isToday = (yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && _this.days[i] == new Date().getDate());
	   		if (_this.days[i] != "")
	      	{
	      		da.innerHTML = _this.days[i];
		        da.className = isToday ? "select-day" : "other-day";
				var _disabled = true;
				if(_last.control != null)
				{
					if(parseInt(_this.year) < parseInt(_last.year)) _disabled = false;
					if(parseInt(_this.year) == parseInt(_last.year) && parseInt(_this.month) < parseInt(_last.month)) _disabled = false;
					if(parseInt(_this.year) == parseInt(_last.year) && parseInt(_this.month) == parseInt(_last.month) && parseInt(da.innerHTML) < parseInt(_last.day)) _disabled = false;
				}
				/*判断规则日期*/
				if(typeof _this.obj.rules == "object" && _disabled)
				{
					if(_this.obj.rules.from)
					{

						var _fromYear = _this.obj.rules.from.split(_re)[0];
						var _fromMonth = _this.obj.rules.from.split(_re)[1];
						var _fromDay = _this.obj.rules.from.split(_re)[2];

						//alert(_this.obj.refers);


						var _endYear = _this.obj.rules.end.split(_re)[0];
						var _endMonth = _this.obj.rules.end.split(_re)[1];
						var _endDay = _this.obj.rules.end.split(_re)[2];

						if(parseInt(_this.year) < parseInt(_fromYear) || parseInt(_this.year) > parseInt(_endYear)){
						   _disabled = false;
						}

						if((parseInt(_this.year) == parseInt(_fromYear) && parseInt(_this.month) < parseInt(_fromMonth,10)) || (parseInt(_this.year) == parseInt(_endYear) && parseInt(_this.month) > parseInt(_endMonth,10))){
							_disabled = false;
						}
						if((parseInt(_this.year) == parseInt(_fromYear) && parseInt(_this.month) == parseInt(_fromMonth,10) && parseInt(da.innerHTML) < parseInt(_fromDay,10)) || (parseInt(_this.year) == parseInt(_endYear) && parseInt(_this.month) == parseInt(_endMonth,10) && parseInt(da.innerHTML) > parseInt(_endDay,10))){
							_disabled = false;
						}
					}
				}

				if(_disabled)
				{
					da.style.cursor="pointer";
					da.onclick = _setTime;
					da.index = _this.days[i];
					if(!isToday)
					{
						da.style.backgroundColor = "#fff";
						da.style.color = "#07679C";
						da.onmouseover = function()
						{
							this.style.backgroundColor = "#07679C";
							this.style.color = "#ffffff";
						};
						da.onmouseout = function()
						{
							this.style.backgroundColor = "";
							this.style.color = "#07679C";
						};

						if(timeFormat(_this.curControl.value))
						{
							if(_this.curControl.value.split(_re)[2] == da.index)
							{
								da.style.backgroundColor = "#07679C";
								da.style.color = "#fff";
							}
						}
					}
					else
					{
						da.style.color = "#fff";
						da.style.backgroundColor = "#043C59";
						da.onmouseover = null;
   						da.onmouseout = null;
					}
				}
				else
				{
					da.style.cursor = "default";
					da.style.color = "#999";
					da.style.backgroundColor = "#fff";
   					if(da.onclick) da.onclick = null;
   					da.onmouseover = null;
   					da.onmouseout = null;
				}
	      	}
	    	else
	    	{
				da.className = "";
	    		da.innerHTML = "";
	    		da.style.backgroundColor = "#fff";
	    		da.style.cursor = "default";
				da.onmouseover = null;
   				da.onmouseout = null;
	    	}
	  	}
	};
	/**
	 * 初始化时间控件
	 */
	var _init = function()
	{
		var _p = document.documentElement.firstChild;
		var _c = document.createElement("link");
		_c.type = "text/css";
		_c.href = "https://www.tenpay.com/v2.0/time/time.css";
		_c.rel = "stylesheet";
		//_p.appendChild(_c);

		var _dv = document.createElement("div");
		_dv.id = "dvTimerMain";
		_dv.style.cssText = "border:1px solid #9DB0BC; width:178px; text-align:center;";

		var _dv2 = document.createElement("div");
		_dv2.className = "date-select";
		var _sn1 = document.createElement("span");
		var _sn2 = document.createElement("span");
		_sn1.id = "snTimerMonthList";
		_sn2.id = "snTimerYearList";
		_dv2.appendChild(_sn1);
		_dv2.appendChild(_sn2);

		_dv.appendChild(_dv2);

		var _dv3 = document.createElement("div");
		_dv3.style.backgroundColor = "#ffffff";
		var _text = "";
		_text = '<table border="0" cellspacing="0" width="100%" class="time-list"><tr><th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr>';
		_text += '</table>';
		_text += '<table border=0 cellspacing=0 cellpadding=0 width=100% height=120 class="date-list">';

		var n=0;
		for (var j=0;j<6;j++)
		{
			_text += ' <tr>';
			for (var i=0;i<7;i++)
			{
				_text += '<td id=timerItem'+n+' ></td>';
				n++;
			}
			_text += '</tr>';
		}

		_text += "<tr id='todayDate'><td colspan='7' class='day-msg'><a id='set-today'";
		if(hideToday){
		  _text+=" style='display:none;' ";
		}
		_text+=" href='javascript:void(0);'>今天</a></td></tr>";
		_text += "</table>";
		_dv3.innerHTML = _text;

		_dv.appendChild(_dv3);

		var _dvMain = document.createElement("div");
		_dvMain.setAttribute("id","dvTimerContainer");
		_dvMain.style.cssText = "display:none; position:absolute;";
		document.body.appendChild(_dvMain);

		if(_isIE6)
		{
			var _ie = document.createElement("iframe");
			_ie.src = "https://www.tenpay.com/v2.0/inc/none.html";
			_ie.style.cssText = "width:178px;height:178px;position:absolute;top:0;z-index:-1;";
			_$("dvTimerContainer").appendChild(_ie);
		}

		_$("dvTimerContainer").appendChild(_dv);

		_$("dvTimerContainer").onmousedown = _clearEvent;
		_$("set-today").onclick = function()
		{
			_this.curControl.value = _getToday();
			_$("dvTimerContainer").style.display = "none";
			if(_this.obj.evn && typeof(_this.obj.evn[_this.curIndex]) == "function")
			{
				_this.obj.evn[_this.curIndex].call(null); //触发点击事件
			}
			if(typeof _this.obj.callback =='function'){//是否有回调函数
				 _this.obj.callback(_this.curControl);
			}else if(typeof global_select_time_callback =='function'){//是否有回调函数
				 global_select_time_callback(_this.curControl);
			}

		};
		if(document.all)
		{
			document.attachEvent(
				"onmousedown",
				function()
				{
					if(_$("dvTimerContainer")) _$("dvTimerContainer").style.display = "none";
				}
			);
		}
		else
		{
			document.addEventListener("mousedown",function()
			{
				if(_$("dvTimerContainer")) _$("dvTimerContainer").style.display = "none";
			},
			false
			);
		}
	};
	var timeFormat = function(s)
	{
		var _r = /\d{8}/;
		if(_r.test(s)) return s;
		if(isNaN(s.replace(_re,""))) return false;
		var _l = s.split(_re);
		if(_l.length !== 3) return false;
		if(parseInt(_l[0],10) <= 0 || parseInt(_l[1],10) <= 0 || parseInt(_l[2],10) <= 0) return false;
		_l[1] = _l[1].length == 1 ? "0" + _l[1] : _l[1];
		_l[2] = _l[2].length == 1 ? "0" + _l[2] : _l[2];
		return (_l[0] + _l[1] + _l[2]);
	};
	if(document.all) window.attachEvent("onload",_init);
	else window.addEventListener("load",_init,false);
	return	{
		bind : _bindControl,
		format : timeFormat
	};
}
)();

function quan2ban(str)
{
	var arr=[];

	arr["０"]="0", arr["１"]="1", arr["２"]="2", arr["３"]="3", arr["４"]="4",
	arr["５"]="5", arr["６"]="6", arr["７"]="7", arr["８"]="8", arr["９"]="9",
	arr["Ａ"]="A", arr["Ｂ"]="B", arr["Ｃ"]="C", arr["Ｄ"]="D", arr["Ｅ"]="E",
	arr["Ｆ"]="F", arr["Ｇ"]="G", arr["Ｈ"]="H", arr["Ｉ"]="I", arr["Ｊ"]="J",
	arr["Ｋ"]="K", arr["Ｌ"]="L", arr["Ｍ"]="M", arr["Ｎ"]="N", arr["Ｏ"]="O",
	arr["Ｐ"]="P", arr["Ｑ"]="Q", arr["Ｒ"]="R", arr["Ｓ"]="S", arr["Ｔ"]="T",
	arr["Ｕ"]="U", arr["Ｖ"]="V", arr["Ｗ"]="W", arr["Ｘ"]="X", arr["Ｙ"]="Y",
	arr["Ｚ"]="Z", arr["ａ"]="a", arr["ｂ"]="b", arr["ｃ"]="c", arr["ｄ"]="d",
	arr["ｅ"]="e", arr["ｆ"]="f", arr["ｇ"]="g", arr["ｈ"]="h", arr["ｉ"]="i",
	arr["ｊ"]="j", arr["ｋ"]="k", arr["ｌ"]="l", arr["ｍ"]="m", arr["ｎ"]="n",
	arr["ｏ"]="o", arr["ｐ"]="p", arr["ｑ"]="q", arr["ｒ"]="r", arr["ｓ"]="s",
	arr["ｔ"]="t", arr["ｕ"]="u", arr["ｖ"]="v", arr["ｗ"]="w", arr["ｘ"]="x",
	arr["ｙ"]="y", arr["ｚ"]="z",
	arr["（"]="(", arr["）"]=")", arr["〔"]="[", arr["〕"]="]", arr["【"]="[",
	arr["】"]="]", arr["〖"]="[", arr["〗"]="]", arr["“"]="[", arr["”"]="]",
	arr["‘"]="[", arr["’"]="]", arr["｛"]="{", arr["｝"]="}", arr["《"]="<",
	arr["》"]=">",
	arr["％"]="%", arr["＋"]="+", arr["—"]="-", arr["－"]="-", arr["～"]="-",
	arr["："]=":", arr["。"]=".", arr["、"]=",", arr["，"]=".", arr["、"]=".",
	arr["；"]=",", arr["？"]="?", arr["！"]="!", arr["…"]="-", arr["‖"]="|",
	arr["”"]="\"", arr["’"]="`", arr["‘"]="`", arr["｜"]="|", arr["〃"]="\"",
	arr["　"]=" ";
	for(var i in arr){
		if(str.indexOf(i)>=0){
			var p=new RegExp(i,'g');
			str=str.replace(p,arr[i]);
		}
	}
	return str;
}
function changeSlideLiColor(oLi){
	$(oLi).css('color','#333');
}
function changColor(oinput){
	$(oinput).css('color','#333');
}
////////////////////////////////////flash ajax请求////////////////////////////////////////////////////////////////////////////
function mainpricecity30(city,input_id){
$('#'+input_id).css('color','#333');
var fromcity = $("#fromcity4").val();
var tocity = $("#tocity44").val();
 if(!checkFormCity('fromcity4','tocity44')){
	  return;
}

	  var day = new Date();
	  var random_num = day.getTime()+Math.floor(Math.random()*100000);
	  $.ajax({
		 type: "GET",
		 url:  base_pages+"/interface/ajax_ticket.php",
		 data: "act=openflashchart&fromcity=" + encodeURI(fromcity) + "&tocity=" + encodeURI(tocity) + "&random="+random_num,
		 success: function(msg){
		   $(".city_pic").html(msg);
		 }
	  });
}