(function(){var Q=null,Z=null,d={},O={},N={},L={},K=false,J=-1,I=null,l="",b=null,g=false,e="",i=0,h=0,S;function T(j,f,n,m){d=j;b=f;S=m;h=n;Z=document.createElement("table");Z.id="suggesttable";Z.className="club_suggest_table";Z.cellPadding=0;Z.cellSpacing=2;Z.style.visibility="hidden";document.body.appendChild(Z);d.setAttribute("autocomplete","off");A(d,"keyup",X);A(d,"blur",k);A(d,"keydown",B);e=(l=d.value);window.setInterval(F,10);}function A(m,f,j){if(m.addEventListener){m.addEventListener(f,j,false);}else{if(m.attachEvent){m.attachEvent("on"+f,j);}}}function F(){e=d.value;if(e!=l){U(0);}}function B(j){var f=j.keyCode;if(f=="27"){k();return ;}if(M(f)){U(f);}}function X(f){var j=f.keyCode;if(!M(j)){U(j);}}function U(f){var j=e;if(j==""){l="";if(f!=0){k();}return ;}if(f=="39"){l="";}if(M(f)===true){g=true;R(f);return ;}if(l==j){return ;}if(g===true){l=j;g=false;return ;}C(j);}function C(f){O={};N={};K=false;J=-1;l=f;if(typeof L[f]!="undefined"){V(f,L[f]);return ;}W("/suggest.php?type="+h+"&k="+encodeURI(f),function(){L[f]=response_json_value;V(f,response_json_value);});}function W(m,n){var j=document.createElement("script");if(j.addEventListener){j.addEventListener("load",n,false);}else{if(j.attachEvent){j.attachEvent("onreadystatechange",function(){if(j.readyState=="loaded"){n.call(j);}});}}j.src=m;document.getElementsByTagName("head")[0].appendChild(j);}function M(f){return f=="38"||f=="40"||f=="13";}function R(f){if(K===true){if(f=="38"){D(J-1);}else{if(f=="40"){D(J+1);}else{if(f=="13"){if(J>=0){G();}}}}}else{H();}}function D(j){var f=I.length;if(j>=f){j=0;}else{if(j<-1){j=f-1;}else{if(j==-1){return ;}}}if(Q){Q.className="";}I[j].className="selected";J=j;Q=I[j];}function V(o,m){L[o]=m;while(Z.rows.length>0){Z.deleteRow(-1);}if(!m||m==""){if(S && o!='快速查找明星'){a(S);}else{k();}return ;}var f=m.length;for(var j=0;j<f;j++){var n=Z.insertRow(-1);n.onmouseover=E;n.onmousedown=G;var p=document.createElement("td");P(p,m[j].words);n.appendChild(p);O[j]=m[j].words;N[j]=m[j].uid;}I=Z.rows;H();}function G(){i=N[J];k();b(i);}function P(j,f){j.appendChild(document.createTextNode(f));}function E(){if(Q){Q.className="";}this.className="selected";Q=this;for(var f=0;f<I.length;f++){if(I[f]==Q){J=f;break;}}}function k(){Z.style.visibility="hidden";K=false;}function H(){K=true;Z.style.visibility="visible";c();}function c(){Z.style.left=Y(d,"offsetLeft")+"px";Z.style.top=(Y(d,"offsetTop")+d.offsetHeight+1)+"px";}function Y(m,j){var f=0;while(m){f+=m[j];m=m.offsetParent;}return f;}function a(f){while(Z.rows.length>0){Z.deleteRow(-1);}var j=Z.insertRow(-1);var m=document.createElement("td");P(m,f);j.appendChild(m);H();}window.simple_suggest={install:T,fill:V,it:a};})();
