var Suggest=function(F,E,C,D,G,A,B){this.options=B?B:[200,800,0.95,"solid","#EEE","#FFF",3,3,0.2,"#000","#444","#F1F5FC",true];this.word=E;this.configuration=G;this.functionReturn=A;this.arrayPrepareKeys=[];this.intPrepareKeysMaxLength=50;this.createContainer=function(R){var L=function(d){var c=";";var b=["width","height","left","top"];for(var a=0;a<4;a++){if(d[a]!="auto"){c+=b[a]+":"+d[a]+(typeof d[a]=="string"?"":"px")+";"}}return c};var Y=["Top","Right","Bottom","Left"];var T=[];var J=";background-color:"+(R.style.backgroundColor?R.style.backgroundColor:this.options[5])+";";for(var V=0;V<4;V++){var M=R.style["border"+Y[V]+"Width"];T[V]=M?M.replace("px","")*1:2;J+="border-"+Y[V].toLowerCase()+"-width:"+T[V]+"px;";var O=R.style["border"+Y[V]+"Style"];J+="border-"+Y[V].toLowerCase()+"-style:"+(O?O:this.options[3])+";";var N=R.style["border"+Y[V]+"Color"];J+="border-"+Y[V].toLowerCase()+"-color:"+(N?N:this.options[4])+";"}var Q=R.clientWidth;Q=Q<this.options[0]?this.options[0]:Q;Q=this.options[1]<Q?this.options[1]:Q;var S="";var U="";var I=";font-size:0px;line-height:0px;";if(navigator.appName=="Microsoft Internet Explorer"){S="filter:alpha(opacity="+this.options[2]*100+");";U="filter:alpha(opacity="+this.options[8]*100+");"}else{S="opacity:"+this.options[2]+";";U="opacity:"+this.options[8]+";"}var K=document.createElement("span");R.parentNode.insertBefore(K,R);var P=R.clientHeight+T[0]+T[2]+(R.offsetTop-K.offsetTop);K.style.position="relative";K.style.display="none";K.style.zIndex=100000;var Z=document.createElement("div");Z.style.position="absolute";Z.style.cssText+=L([Q,"auto",0,P])+J+S;K.appendChild(Z);var X=document.createElement("div");X.style.position="absolute";X.style.cssText+=L([this.options[6],Z.clientHeight+T[1]+T[3],Q+T[0]+T[2],P+this.options[7]])+"background-color:"+(R.style.borderRightColor?R.style.borderRightColor:this.options[9])+";"+U+I;K.appendChild(X);var H=document.createElement("div");H.style.position="absolute";H.style.cssText+=L([Q+T[0]+T[2]-this.options[6],this.options[7],this.options[6],P+Z.clientHeight+T[1]+T[3]])+"background-color:"+(R.style.borderBottomColor?R.style.borderBottomColor:this.options[9])+";"+U+I;K.appendChild(H);var W=document.createElement("div");W.style.position="absolute";W.style.cssText+=L([Q<R.clientWidth?Q:R.clientWidth,T[2]+T[0],T[3],P-T[2]])+";background-color:"+(R.style.backgroundColor?R.style.backgroundColor:this.options[5])+";"+I;if(R.style.borderBottomWidth){K.appendChild(W)}this.elementSpan=K;this.elementDiv=Z;this.elementShadowDivRight=X;this.elementShadowDivBottom=H};this.romance=function(H){H.style.cursor="pointer";H.suggest=this;H.onmouseover=function(){this.style.color=this.suggest.options[10];this.style.backgroundColor=this.suggest.options[11]};H.onmouseout=function(){this.style.color="";this.style.backgroundColor=""};H.onmousedown=function(){this.suggest.booleanForceScan=false;this.suggest.elementTarget.value=this.suggest.elementTarget.value.replace(/[^,]*$/,this.data[this.suggest.configuration[5]]);if(this.suggest.functionReturn){this.suggest.functionReturn(this.suggest.elementTarget.value)}this.suggest.hide()}};this.resetShadow=function(){var H=this.elementDiv.clientHeight+this.elementDiv.style.borderTopWidth.replace("px","")*1+this.elementDiv.style.borderBottomWidth.replace("px","")*1;this.elementShadowDivRight.style.height=H+"px";this.elementShadowDivBottom.style.top=this.elementDiv.style.top.replace("px","")*1+H+"px"};this.resetSuggest=function(J){this.setLine(null);this.elementDiv.innerHTML="";if(J.length==0){this.hide();return}var N="width:100%; color:#999; font-size:12px; text-align:center; line-height:20px;";var K=document.createElement("table");K.style.cssText+=N;K.cellPadding=0;K.cellSpacing=0;var P=K.insertRow(0);P.style.cssText+="background-color:#F3F3F3;";for(var M=0;M<this.configuration[3].length;M++){var H=P.insertCell(M);H.innerHTML=this.configuration[3][M]}for(var M=0;M<J.length;M++){var Q=K.insertRow(M+1);Q.data=J[M];this.romance(Q);for(var L=0;L<J[M].length;L++){var H=Q.insertCell(L);H.innerHTML=J[M][L]}}this.elementTable=K;this.elementDiv.appendChild(K);if(this.options[12]){if(navigator.appVersion.indexOf("MSIE 6.0")!=-1){var O=document.getElementsByTagName("select");var I=O.length;for(var M=0;M<I;M++){O[M].style.visibility="hidden"}}}if(this.elementSpan.innerHTML!=""){this.elementSpan.style.display="";this.resetShadow()}return};this.hide=function(){if(this.options[12]){if(navigator.appVersion.indexOf("MSIE 6.0")!=-1){var I=document.getElementsByTagName("select");var J=I.length;for(var H=0;H<J;H++){I[H].style.visibility=""}}}this.elementSpan.style.display="none"};this.load=function(H,J){var I=document.createElement("script");I.type="text/javascript";I.language="javascript";I.charset="utf-8";I.src=H;I.suggest=this;I.key=J;I[document.all?"onreadystatechange":"onload"]=function(){if(document.all&&this.readyState!="loaded"&&this.readyState!="complete"){return}this.suggest.stringData+=window[this.key];this[document.all?"onreadystatechange":"onload"]=null;this.parentNode.removeChild(this)};this.elementSpan.appendChild(I)};this.getResult=function(M){if(!this.stringData||M==""||M.indexOf("\\")!=-1){return new Array()}var J="$()*+.[?^{|";for(var P=0;P<J.length;P++){if(M.indexOf(J.substr(P,1))!=-1){return new Array()}}if(M.indexOf(",")!=-1&&M.indexOf(",")!=0&&M.indexOf(",")!=M.length-1){var O=M.split(",");M=O[O.length-1]}var S="";var T=false;for(var P=0;P<this.arrayPrepareKeys.length;P++){if(this.arrayPrepareKeys[P][0]==M){S=this.arrayPrepareKeys[P][1];T=true}if(M.match(new RegExp("^"+this.arrayPrepareKeys[P][0],"igm"))!=null){S=this.arrayPrepareKeys[P][1]}}var L=(S==""?this.stringData:S).match(new RegExp(this.configuration[0].replace(new RegExp(this.configuration[1],"g"),M),"igm"));if(L==null){return new Array()}var X=[],V=[];for(var P=0;P<L.length;P++){var W=L[P];if(V[W]!=1){X.push(W);V[W]=1}}V=null;L=X;X=null;if(!T){this.arrayPrepareKeys.push([M,L.join("")]);if(this.arrayPrepareKeys.length>this.intPrepareKeysMaxLength){this.arrayPrepareKeys.sort(function(Z,Y){return Z[0].length-Y[0].length});this.arrayPrepareKeys.pop()}}L.length=L.length>this.configuration[6]?this.configuration[6]:L.length;if(this.configuration[7]&&M.match(this.configuration[7][0])!=null){var R=this.configuration[7][1].replace(this.configuration[1],M);var H=this.configuration[7][2]}else{var R="^("+M+")";var H='<span style="color:#F00;">$1</span>'}for(var P=0;P<L.length;P++){var U=L[P].split(new RegExp(this.configuration[2]));var K=[];var Q="";for(var N=0;N<U.length;N++){if(U[N]!=""){if(U[N].match(new RegExp(R,"i"))&&Q==""){Q=U[N].replace(new RegExp(R,"i"),H)}K.push(U[N])}}var I=[];for(var N=0;N<this.configuration[4].length;N++){if(this.configuration[4][N]==-1){I[N]=Q}else{I[N]=K[this.configuration[4][N]]}}L[P]=I}return L};this.scan=function(){var H=arguments.callee.suggest;if(H.booleanForceScan){if(H.stringLastValue!=H.elementTarget.value){H.stringLastValue=H.elementTarget.value;H.resetSuggest(H.getResult(H.elementTarget.value.match(/[^,]*$/)[0]))}}};this.scan.suggest=this;this.setLine=function(H){if(this.lineCurrent){this.lineCurrent.style.color="";this.lineCurrent.style.backgroundColor=""}this.lineCurrent=null;if(H){this.lineCurrent=H;this.lineCurrent.style.color=this.options[10];this.lineCurrent.style.backgroundColor=this.options[11];this.elementTarget.value=this.elementTarget.value.replace(/[^,]*$/,H.data[this.configuration[5]].replace('<span style="color:#F00;">',"").replace("</span>",""))}};this.bind=function(M,I,K){if(typeof M=="string"){var L=document.getElementById(M)}else{var L=M}this.elementTarget=L;var H=this.createContainer(L);if(K==null){this.stringData=I}else{if(typeof I!="string"){for(var J=0;J<I.length;J++){this.load(I[J],K[J])}}else{this.load(I,K)}}L.autocomplete="off";L.suggest=this;if(L.value!=E){L.value=E}L.onfocus=function(){if(this.value==this.suggest.word){}this.style.color="";this.suggest.stringLastValue="";this.suggest.booleanForceScan=true;this.suggest.intThread=setInterval(this.suggest.scan,10)};L.onblur=function(){if(this.value==""){}this.suggest.hide();clearInterval(this.suggest.intThread);this.suggest.intThread=-1};L.onkeydown=function(){if(this.value==this.suggest.word){this.value=""}var O=arguments[0]||window.event;var Q=this.suggest;switch(O.keyCode){case 38:this.suggest.booleanForceScan=false;if(!Q.lineCurrent||Q.lineCurrent.rowIndex==1){Q.setLine(Q.elementTable.rows[Q.elementTable.rows.length-1])}else{Q.setLine(Q.elementTable.rows[Q.lineCurrent.rowIndex-1])}return false;break;case 40:this.suggest.booleanForceScan=false;if(!Q.lineCurrent||Q.lineCurrent.rowIndex==Q.elementTable.rows.length-1){Q.setLine(Q.elementTable.rows[1])}else{Q.setLine(Q.elementTable.rows[Q.lineCurrent.rowIndex+1])}return false;break;case 13:this.suggest.booleanForceScan=false;if(this.suggest.lineCurrent){this.suggest.elementTarget.value=this.suggest.elementTarget.value.replace(/[^,]*$/,this.suggest.lineCurrent.data[this.suggest.configuration[5]])}if(this.suggest.functionReturn){if(this.suggest.lineCurrent){var P=[];for(var N=0;N<this.suggest.lineCurrent.data.length;N++){P[N]=this.suggest.lineCurrent.data[N].replace('<span style="color:#F00;">',"").replace("</span>","")}this.suggest.functionReturn(this.suggest.elementTarget.value,P)}else{this.suggest.functionReturn(this.suggest.elementTarget.value)}}this.suggest.hide();break;default:this.suggest.booleanForceScan=true;this.suggest.scan();break}}};this.bind(F,C,D);this.getData=function(J){var I=this.getResult(J);if(I.length==1){var K=[];for(var H=0;H<I[0].length;H++){K[H]=I[0][H].replace('<span style="color:#F00;">',"").replace("</span>","")}return K}else{return null}}};var StockSuggestConfiguration=["(~[^~`]*(`[^~`]*)*`@KEY@[^~`]*(`[^~`]*)*)|(~@KEY@[^~`]*`[^~`]*`[^~`]*)","@KEY@","[~`]",["\u9009\u9879","\u4ee3\u7801","\u540d\u79f0"],[-1,0,1],1,10,[/^\d+/,"^(@KEY@)",'<span style="color:#F00;">$1</span>']];

