var $=function(a){return document.getElementById(a)};function init(){initHtmlContent();initHeaderSearch();initTabTools();initFooterSearch();$("top-set-homepage").onclick=function(){Core.setHomepage("http://13393.com/");return false};$("footer-add-to-favorites").onclick=function(){Core.addToFavorite("http://13393.com/","13393傲游网址导航");return false};if($("index")){initLayout();initDatetime();initEmail();$("adv").innerHTML=data13393.html.adv;$("weather-content").src=data13393.links.weather}}function initHtmlContent(){$("top-menu").innerHTML=data13393.html.topMenu;$("footer-links").innerHTML=data13393.html.footerLinks;$("header-search-menu").innerHTML=data13393.html.headerSearch;$("footer-search-menu").innerHTML=data13393.html.footerSearch;$("header-search-more").innerHTML=data13393.html.moreSearch}function initLayout(){var c=$("tags");var d=$("content");var e=$("tools");var b=$("special");var a=d.offsetHeight;c.style.height=a-4+"px";b.style.height=a-6+"px"}function initDatetime(){var f=$("inner-datetime");if(!f){return}var d=new Date();config.datetime=d;var c=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"][d.getDay()];var e=d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日";var b=Calendar.parseDate(d);var a=b.lunarDate;var g="万年历";if(b.fest.major.length>0||b.fest.normal.length>0||b.fest.minor.length>0){g=b.fest.major.join(" ")+b.fest.normal.join(" ")+b.fest.minor.join(" ")}f.innerHTML='<span style="color:#74582b">'+e+"</span><br /><strong>"+a+"</strong> "+c+'<br /> <a href="'+data13393.links.festival+'">'+g+'</a> <a href="'+data13393.links.calendar+'">星座运程</a>'}function initHeaderSearch(){var l=$("header-search-input");if(!l){return}var b=$("header-search-menu");var c=$("header-search-btn");var k=$("header-search-icon");var i=$("header-search-more");var g=b.getElementsByTagName("a");var f;var m;d(g[0]);a();j();Search.bindInputEvent(l,"headerSearch");Search.bindBtnEvent(c,l,"headerSearch");function d(n){if(n==f){return}if(n.name=="more"){e();return}if(f){f.className=""}if(m){m.className=""}f=n;f.className="current";m=f.previousSibling;if(m){m.className="last"}config.headerSearch=data13393.search[n.name];k.style.backgroundImage="url("+config.headerSearch.iconSrc+")";c.innerHTML=config.headerSearch.btnLabel}function a(){for(var n=0;n<g.length;n++){var o=g[n];o.onclick=function(p){p=p||window.event;var q=p.target||p.srcElement;if(q.tagName.toLowerCase()!=="a"){q=q.parentNode}d(q);l.focus();return false}}}function j(){window.onresize=h}function h(){var n=g[g.length-1];var o=Core.getPosition(n);i.style.left=o.left-1+"px";i.style.top=o.top-1+"px"}function e(){h();i.style.display="block";setTimeout(function(){document.body.onclick=function(){i.style.display="none";document.body.onclick=null}},100)}}function initTabTools(){var g=$("tab-header");if(!g){return}var b=$("websites");var d=g.getElementsByTagName("a");var f=d[0];a();function e(h){if(h==f){return}if(f){f.className=""}f=h;f.className="current";config.tabCurrent=data13393.tabtools[h.name];c(config.tabCurrent,h.name)}function c(k,h){var i=k.type;var j=k.link;var l=$("tab-"+h);b.style.display="none";switch(i){case"dom":$(j).style.display="";b=$(j);break;case"url":if(l.src==""||l.src.indexOf(j)<0){l.src=j}l.style.display="block";b=l;break}}function a(){for(var h=0;h<d.length;h++){var j=d[h];j.onclick=function(i){i=i||window.event;var k=i.target||i.srcElement;if(k.tagName.toLowerCase()!=="a"){k=k.parentNode}e(k);if(config.tabTimer){clearTimeout(config.tabTimer);config.tabTimer=null}return false};j.onmouseover=function(i){i=i||window.event;var k=i.target||i.srcElement;if(k.tagName.toLowerCase()!=="a"){k=k.parentNode}config.tabTimer=setTimeout(function(){e(k)},300);return false};j.onmouseout=function(i){if(config.tabTimer){clearTimeout(config.tabTimer);config.tabTimer=null}return false}}}}function initFooterSearch(){var a=$("footer-search-input");if(!a){return}var g=$("footer-search-menu");var b=$("footer-search-btn");var d=g.getElementsByTagName("input");var f;e(d[0]);c();Search.bindInputEvent(a,"footerSearch");Search.bindBtnEvent(b,a,"footerSearch");function e(h){config.footerSearch=data13393.search[h.value];b.innerHTML=config.footerSearch.btnLabel}function c(){for(var h=0;h<d.length;h++){var j=d[h];j.onclick=function(i){i=i||window.event;var k=i.target||i.srcElement;e(k);a.focus()}}}}function initEmail(){var g=$("email-username");if(!g){return}var c=$("email-password");var e=$("email-channel");var b=$("email-btn-login");var a=$("email-btn-register");e.selectedIndex=0;f("13393");d();Email.bindInputEvent(g,c,"email");Email.bindLoginBtnEvent(b,g,c,"email");function f(h){if(h!="13393"){var i=data13393.email[h];config.email=i;a.href=data13393.email[h].registerUrl;a.onclick=function(){return true};if(i.isLink){Core.getForm(i.loginUrl)}}else{config.email="13393.com";a.href="#";a.onclick=function(){alert("请先选择您要登录的邮箱或社区!");return false};return}}function d(){e.onchange=function(h){h=h||window.event;var i=h.target||h.srcElement;f(i.value)}}}var Core={getForm:function(a,b){Form.submit("get",a,null,b)},postForm:function(a,b,c){Form.submit("post",a,b,c)},initInput:function(a,c){var b=arguments[2]||"";a.onfocus=function(){if(a.className=="novalue"){a.value=""}a.className=b};a.onblur=function(){if(a.value==""){a.className="novalue";a.value=c}};a.className="novalue";a.value=c},isEmptyInput:function(a){return(a.className=="novalue"||a.value==""||/^\s*$/.test(a.value))},getPosition:function(c){var b=0;var a=0;while(c){b+=c.offsetLeft;a+=c.offsetTop;c=c.offsetParent}return{left:b,top:a}},setHomepage:function(b){if(document.all){document.body.style.behavior="url(#default#homepage)";document.body.setHomePage(b)}else{if(window.sidebar){if(window.netscape){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");var a=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);a.setCharPref("browser.startup.homepage",b)}catch(c){alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true")}}}}},addToFavorite:function(a,c){try{if(window.external||window.external.addFavorite){window.external.addFavorite(a,c)}else{if(window.sidebar){window.sidebar.addPanel(c,a,"")}}}catch(b){}}};var Search={bindInputEvent:function(a,b){Core.initInput(a,"请输入关键字");a.onkeydown=function(c){c=c||window.event;if(c.keyCode==13){Search.doSearch(a,b)}}},bindBtnEvent:function(b,a,c){b.onclick=function(){Search.doSearch(a,c);return false}},doSearch:function(a,d){var c=config[d];if(Core.isEmptyInput(a)){Core.getForm(c.link);return}var b=a.value;b=encodeURIComponent(b);Core.getForm(c.url+b,c.charset);a.value=""}};var Email={bindInputEvent:function(c,a,b){Core.initInput(c,"请输入用户名");Core.initInput(a,"password");c.onkeydown=a.onkeydown=function(d){d=d||window.event;if(d.keyCode==13){Email.doLogin(c,a,b)}}},bindLoginBtnEvent:function(b,d,a,c){b.onclick=function(){if(config.email!=="13393.com"){Email.doLogin(d,a,c)}else{alert("请先选择您要登录的邮箱或社区！")}return false}},bindRegisterBtnEvent:function(a,b){a.onclick=function(){Email.doRegister(b);return false}},doLogin:function(g,a,f){var c=config[f];if(c.isLink){Core.getForm(c.loginUrl);return}if(Core.isEmptyInput(g)){alert("请输入账户名");return}if(Core.isEmptyInput(a)){alert("请输入密码");return}var e=g.value;var b=a.value;var d=c.getParams(e,b);Core.postForm(c.loginUrl,d,c.charset);a.value=""},doRegister:function(b){var a=config[b];Core.getForm(a.registerUrl)}};var Form={createInput:function(b,c){var a=document.createElement("input");a.type="hidden";a.name=b;a.value=c;return a},parseQueryString:function(a){var h=a.indexOf("?");if(h<0){return{action:a,params:{}}}var f=a.substr(0,h);var g={};var e=a.substr(h+1,a.length);e=e.split("&");for(var c=0;c<e.length;c++){h=e[c].indexOf("=");var b=e[c].substr(0,h);var d=e[c].substr(h+1,e[c].length);g[b]=decodeURIComponent(d)}return{action:f,params:g}},submit:function(h,e,f,g){if(!h){h="get"}if(!g){g="utf-8"}if(h=="get"){var a=Form.parseQueryString(e);e=a.action;f=a.params}var d=$("form");d.innerHTML="";d.method=h;d.action=e;d.setAttribute("accept-charset",g);document.charset=g;for(var c in f){var b=Form.createInput(c,f[c]);d.appendChild(b)}d.submit()}};var Chaxun={init:function(){this.bindUI();Chaxun.Bus.init();Chaxun.Train.init()},bindUI:function(){Core.initInput($("phone-num"),"前7位或11位手机号","search-text");Core.initInput($("post-num"),"","search-text");Core.initInput($("plane-s"),"出发城市","search-text");Core.initInput($("plane-t"),"到达城市","search-text");Core.initInput($("plane-d"),"2009-12-31","search-text");Core.initInput($("bus-stat"),"站名(如：天安门东)","search-text");Core.initInput($("bus-road"),"线路(如：290路)","search-text");Core.initInput($("bus-s"),"起点站","search-text");Core.initInput($("bus-t"),"终点站","search-text");Core.initInput($("train-s"),"起点站","search-text");Core.initInput($("train-t"),"终点站","search-text");Core.initInput($("train-num"),"车次(如：T8)","search-text");var d=$("tab-menu").getElementsByTagName("li");for(var b=0,a=d.length;b<a;b++){d[b].onclick=function(){c();$(this.id+"-content").style.display="";this.className="active"}}function c(){for(var f=0,e=d.length;f<e;f++){d[f].className="";$(d[f].id+"-content").style.display="none"}}},_encodeDURI:function(d,c){if(c){return encodeURIComponent(decodeURIComponent(d))}return encodeURI(decodeURI(d))},_decodeDURI:function(d,c){if(c){return decodeURIComponent(decodeURIComponent(d))}return decodeURI(decodeURI(d))}};Chaxun.Bus={init:function(){this.bindUI()},bindUI:function(){var h=this;var b=$("bus-line-submit");var k=$("bus-station-submit");var a=$("bus-transfer-submit");var j=$("bus-form");var g=$("bus-road");var l=$("bus-stat");var d=$("bus-s");var c=$("bus-t");var f=$("bus-content").getElementsByTagName("input");for(var e=0;e<f.length;e++){if(f[e].name=="bustype"){f[e].onclick=function(){h._showBusType(this.value)}}}g.onkeydown=l.onkeydown=c.onkeydown=d.onkeydown=function(m){m=m||window.event;var i=false;if(m.keyCode==13){this.blur();switch(config.busType){case"line":i=h._lineCheck();i?document.all?j.click():null:null;break;case"station":i=h._stationCheck();i?document.all?j.click():null:null;break;case"transfer":i=h._transferCheck();i?document.all?j.click():null:null;break;default:break}}};b.onclick=function(){if(h._lineCheck()){document.all?j.click():window.open(j.href,"_blank")}};k.onclick=function(){if(h._stationCheck()){document.all?j.click():window.open(j.href,"_blank")}};a.onclick=function(){if(h._transferCheck()){document.all?j.click():window.open(j.href,"_blank")}}},_showBusType:function(a){$("bus-line").style.display=$("bus-station").style.display=$("bus-transfer").style.display="none";$("bus-"+a).style.display="";config.busType=a},_lineCheck:function(){var c=$("bus-form");var b=$("bus-city");var a=$("bus-road");if(a.value==""||a.value=="线路(如：290路)"){alert("请输入线路号!");return false}c.href="http://bus.mapbar.com/mapview/index.jsp#ac=line&city="+Chaxun._encodeDURI(b.value,1)+"&keyword="+Chaxun._encodeDURI(a.value,1);return true},_stationCheck:function(){var c=$("bus-form");var b=$("bus-city");var a=$("bus-stat");if(a.value==""||a.value=="站名(如：天安门东)"){alert("请输入公交站名称!");return false}c.href="http://bus.mapbar.com/mapview/index.jsp#ac=station&city="+Chaxun._encodeDURI(b.value,1)+"&keyword="+Chaxun._encodeDURI(a.value,1);return true},_transferCheck:function(){var d=$("bus-form");var c=$("bus-city");var a=$("bus-s");var b=$("bus-t");if(a.value==""||a.value=="起点站"){alert("请输入公交查询起点站名!");return false}if(b.value==""||b.value=="终点站"){alert("请输入公交查询终点站名!");return false}d.href="http://bus.mapbar.com/mapview/index.jsp#ac=bus&city="+Chaxun._encodeDURI(c.value,1)+"&origName="+Chaxun._encodeDURI(a.value,1)+"&destName="+Chaxun._encodeDURI(b.value,1);return true}};Chaxun.Train={init:function(){this.bindUI()},bindUI:function(){var e=$("train-s");var d=$("train-t");var b=$("train-num");var c=$("route-form");var f=$("train-form");var a=$("route-btn");var g=$("train-btn");e.onkeydown=d.onkeydown=function(h){h=h||window.event;if(h.keyCode==13){this.blur();a.click()}};b.onkeydown=function(h){h=h||window.event;if(h.keyCode==13){this.blur();g.click()}};c.onsubmit=function(){if(e.value==""||e.value=="起点站"){alert("请输入起点站名称！");return false}if(d.value==""||d.value=="终点站"){alert("请输入终点站名称！");return false}};f.onsubmit=function(){if(b.value==""||b.value=="车次(如：T8)"){alert("请输入列车车次！");return false}}}};var config={datetime:null,headerSearch:null,footerSearch:null,tabCurrent:null,tabTimer:null,busType:"line",email:null};