function $jw(a){return document.getElementById(a)}$jwevent={getEvent:function(a){return a||event},getCharCode:function(a){var a=this.getEvent(a);return a.keyCode||a.charCode||0}};$jwdom={getY:function(a){var b=a.offsetTop;if(a.offsetParent!=null){b+=this.getY(a.offsetParent)}return b},getX:function(a){var b=a.offsetLeft;if(a.offsetParent!=null){b+=this.getX(a.offsetParent)}return b},getXY:function(a){return{x:this.getX(a),y:this.getY(a)}}};function $trim(a){return a.replace(/(^\s*)|(\s*$)/g,"")}var NetJs={dlcbix:0,dlcbs:{},downloadJs:function(b,e,j,i){var g=document.getElementsByTagName("head")[0];var f=document.createElement("script");f.type="text/javascript";var h=[];for(var c in e){h.push([c,"=",e[c]].join(""))}NetJs.dlcbix++;var d="cb_"+NetJs.dlcbix;NetJs.dlcbs[d]=function(a){j.call(i,a)};f.src=b+h.join("&")+"&cb=NetJs.dlcbs.cb_"+NetJs.dlcbix+"&v="+Math.random();g.appendChild(f)}};NetFSO={dlcbix:0,dlcbs:{},downloadFile:function(c,f,j,i){var h=[];for(var d in f){h.push([d,"=",f[d]].join(""))}NetFSO.dlcbix++;var e="cb_"+NetFSO.dlcbix;NetFSO.dlcbs[e]=function(a){j.call(i,a)};var g=document.createElement("div");var b="jwnetfso"+NetFSO.dlcbix;g.innerHTML='<iframe id="'+b+'" onload="NetFSO.dlcbs.'+e+'(this.window || this.contentWindow);" style="display:none;"></iframe>';document.getElementsByTagName("body")[0].appendChild(g);document.getElementById(b).src=c+h.join("&")+"&v="+Math.random()}};function Template(f,b){Template.jwid++;this.id=Template.jwid;var d={};var e=this.id;var a=0;var c=f.replace(/__NAME__="(\w{0,})"/ig,function(h,g){a++;var i=g+"_"+e+"_"+a;if(typeof d[g]=="undefined"){d[g]=[];d[g].push(a)}else{d[g].push(a)}return'id="jw_'+i+'"'});document.getElementById(b).innerHTML=c;this._els=d;this.rts={}}Template.jwid=0;Template.prototype={getEL:function(f,g,e){if(typeof this._els[f]=="undefined"){return null}var c=[];for(var d=0,a=this._els[f].length;d<a;d++){var b=g.call(e,document.getElementById("jw_"+f+"_"+this.id+"_"+this._els[f][d]));c.push(b)}return c},getEL1:function(a){return document.getElementById("jw_"+a+"_"+this.id+"_"+this._els[a][0])},addRt:function(a){var c=this;var b=this.getEL(a,function(d){if(typeof c.rts[a]=="undefined"){c.rts[a]=d.innerHTML.replace("<!--","").replace("-->","")}})},createRt:function(a){return new TemplateRt(typeof this.rts[a]=="undefined"?"__NAME__ : "+a+" NotFined":this.rts[a])}};function TemplateRt(a){this.tp=a;this.els=[]}TemplateRt.jwid=0;TemplateRt.prototype={get:function(){var b=[];var a=this.tp.replace(/id="(\w{0,})"/ig,function(f,e){var c=e.split("_");c.shift();c.pop();c.pop();var d=c.join("_");var g=e+"_"+TemplateRt.jwid;b.push({n:d,id:g});return'id="'+g+'"'});this.els.push(b);TemplateRt.jwid++;return a},getELs:function(g,f){for(var e=0,a=this.els.length;e<a;e++){var k={};for(var b=0,c=this.els[e].length;b<c;b++){var h=this.els[e][b];k[h.n]=document.getElementById(h.id);k.ix=e}g.call(f,k)}},getELss:function(){var b=[];for(var f=0,a=this.els.length;f<a;f++){var h={};for(var c=0,e=this.els[f].length;c<e;c++){var g=this.els[f][c];h[g.n]=document.getElementById(g.id);h.ix=f}b.push(h)}return b}};var JwCookie={read:function(a){var b=document.cookie.match("(?:^|;)\\s*"+a+"=([^;]*)");return b?b[1]:null},dispose:function(c,b){var a=new Date();a.setTime(a.getTime()+-1*24*60*60*1000);var d=c+"=; domain="+b.domain+"; path="+b.path+"; expires="+a.toString();document.cookie=d;return this}};var JwUser={port:80,urls:{},events:{onLoginSuccess:[],onLoginFailure:[],onLoginStateChange:[]},cookieToken:"$",userInfo:{Gender:"",PpNum:"",ExpNum:"",LevelName:"",NextLevelName:"",NextLevelExpNum:"",Area:"",Subscribe:"",UnreadNotes:"",HeadPic:"",Email:"",OnlineTime:"",UserName:""},logined:false,addEvent:function(c,b,a){if(typeof this.events[c]=="undefined"){alert("未定义 "+c+" 事件,无法进行绑定");return}this.events[c].push([b,a])},__fncEvent:function(d,b){var e=this.events[d];for(var c=0,a=e.length;c<a;c++){e[c][0].call(e[c][1],b)}},init:function(){this.urls={login:"http://passport.pptv.com:"+this.port+"/clientlogin.do?",register:"http://passport.pptv.com:"+this.port+"/registerandlogin.do",forgetpwd:"http://passport.pptv.com:"+this.port+"/fetchpassword.do",userinfo:"http://home.pptv.com",usertips:"http://home.pptv.com/userinbox"};this.tryReadUserInfo()},login:function(a,b){NetFSO.downloadFile(this.urls.login,{IsTest:"OK",username:encodeURIComponent(a),password:encodeURIComponent(b)},function(c){this.tryReadUserInfo()?this.__loginOnSuccess():this.__loginOnFailure()},this)},__loginOnSuccess:function(){this.__fncEvent("onLoginSuccess",null)},__loginOnFailure:function(){this.__fncEvent("onLoginFailure",null)},tryReadUserInfo:function(){if(!JwCookie.read("UDI")){this.__fncEvent("onLoginStateChange",{state:"notlogined",userInfo:null});return false}if(JwCookie.read("PPName")){var b=JwCookie.read("PPName").split(this.cookieToken);this.userInfo.UserName=decodeURIComponent(b[0])}var c=JwCookie.read("UDI").split(this.cookieToken);var a=0;for(var d in this.userInfo){if(d=="UserName"){break}this.userInfo[d]=decodeURIComponent(c[a]);a++}this.logined=true;this.__fncEvent("onLoginStateChange",{state:"logined",userInfo:this.userInfo});return true},logout:function(){var b={domain:"pptv.com",path:"/"};JwCookie.dispose("UDI",b);JwCookie.dispose("PPName",b);JwCookie.dispose("PPKey",b);this.logined=false;for(var a in this.userInfo){this.userInfo[a]=""}this.__fncEvent("onLoginStateChange",{state:"logouted",userInfo:this.userInfo})}};var JwUserUI={init:function(){JwUser.addEvent("onLoginStateChange",function(e){switch(e.state){case"logined":$jw("btn_uname").innerHTML="欢迎您! "+e.userInfo.UserName+"";$jw("btn_uname").style.display="";$jw("btn_logout").style.display="";$jw("btn_login").style.display="none";$jw("btn_register").style.display="none";break;case"notlogined":case"logouted":$jw("btn_uname").style.display="none";$jw("btn_logout").style.display="none";$jw("btn_login").style.display="";$jw("btn_register").style.display="";break}},this);JwUser.addEvent("onLoginSuccess",function(){$jw("loginbox").style.display="none";b(2)},this);JwUser.addEvent("onLoginFailure",function(){b(1)},this);var c=new Template($jw("loginbox").innerHTML,"loginbox");c.getEL1("lb_b1").style.display="none";c.getEL1("lb_b2").style.display="none";var b=function(d){for(var e=0;e<3;e++){c.getEL1("lb_b"+(e+1)).style.display="none"}c.getEL1("lb_b"+(d+1)).style.display="block"};$jw("btn_logout").onclick=function(d){if(confirm("确定退出登录吗?")){JwUser.logout()}return false};c.getEL1("lb_btn_relogin").onclick=function(d){b(2);return false};c.getEL1("lb_btn_close").onclick=function(d){$jw("loginbox").style.display="none";return false};$jw("btn_login").onclick=function(e){var d=$jwdom.getXY($jw("user_btns"));$jw("loginbox").style.display="block";$jw("loginbox").style.top=d.y-10+"px";$jw("loginbox").style.left=(d.x-234)+"px";b(2);return false};var a=function(){var e=c.getEL1("lb_input_pwd").value;var d=c.getEL1("lb_input_name").value;if(d.length==0||e.length==0){return}b(0);JwUser.login(d,e)};c.getEL1("lb_btn_login").onclick=function(d){a();return false};c.getEL1("lb_input_name").onkeyup=function(d){if($jwevent.getCharCode(d)==13){a()}};c.getEL1("lb_input_pwd").onkeyup=function(d){if($jwevent.getCharCode(d)==13){a()}}},showLoginBox:function(a,b){$jw("loginbox").style.display="block";$jw("loginbox").style.top=b+"px";$jw("loginbox").style.left=a+"px"}};function initSearch(){var p=$jw("_j_dom_SearchInput");var o="http://ikan.pptv.com/search/suggest/?";var r=new Image(1,1);var q="http://218.61.6.151/t.gif?rid=4a5ee4943d2be&lt=";var m=document.createElement("ul");m.className="sm_search_tips";m.style.display="none";m.style.position="absolute";m.style.zIndex="50";m.style.left="0px";m.style.top="0px";var d="-- 请输入关键字 --";var a=500;var n=[];var b=[];var h=null;var j="";var i=-1;var e=null;var f=false;function k(){var s=$trim(p.value);if(s==""||s==d){return false}try{location.href="http://ikan.pptv.com/search/?kw="+encodeURIComponent(s)}catch(t){}}function l(t){var s=parseInt(i)+parseInt(t);if(s<0){s=n.length-1}else{if(s>=n.length){s=0}}if(i!=-1){b[i].className=""}i=s;b[i].className="current";p.value=n[i].name}function g(){var s=$trim(p.value);if(s!=""&&s!=d&&s!=j){NetJs.downloadJs(o,{kw:encodeURIComponent(s)},function(t){c(t)});j=s;r.src=q+new Date().getTime()}}function c(v){var u=[];for(var t=0;t<v.length;t++){u.push(['<li><a href="javascript:;" title="',v[t].name,'">',v[t].name.substring(0,12),"</a></li>"].join(""))}m.innerHTML=u.join("");var w=$jwdom.getXY(p);if(!f){f=true;document.getElementsByTagName("body")[0].appendChild(m)}m.style.left=w.x-4+"px";m.style.top=w.y+24+"px";m.style.width="162px";m.style.height=(v.length)*24+"px";m.style.display="block";b=m.getElementsByTagName("li");n=v;for(var t=b.length;t--;){b[t].setAttribute("tid",t);b[t].onclick=function(s){var x=parseInt(this.getAttribute("tid"));location.href=n[x].link;return false}}}p.style.color="#999";p.onfocus=function(t){this.select();var s=$trim(this.value);if(s==""||s==d){this.style.color="#000";this.value=""}};p.onblur=function(t){var s=$trim(this.value);if(s==""||s==d){this.style.color="#999";this.value=d}};p.onkeydown=function(s){var u=$jwevent.getCharCode(s);switch(u){case 13:k();break;case 38:if(m.style.display=="none"){m.style.display=""}l(-1);break;case 40:if(m.style.display=="none"){m.style.display=""}l(1);break;default:try{clearTimeout(h)}catch(t){}h=setTimeout(g,a);break}};$jw("j_dom_searchsubmit").onclick=function(s){k();return false};document.onclick=function(s){m.style.display="none"}}var PageHeader={defaultSearchTxt:"-- 请输入关键字 --",init:function(){JwUserUI.init();JwUser.init();var a=this;$jw("_j_dom_SearchInput").onfocus=function(){if(a.defaultSearchTxt==this.value){this.value=""}};$jw("_j_dom_SearchInput").onblur=function(){if(this.value.replace(/(^\s*)|(\s*$)/g,"")==""){this.value=a.defaultSearchTxt}};initSearch()}};
