function ready(A){if(/(?!.*?compatible|.*?webkit)^mozilla|opera/i.test(navigator.userAgent)){document.addEventListener("DOMContentLoaded",A,false)}else{window.setTimeout(A,0)}}function importJs(C,F,E){var D=document.getElementsByTagName("head")[0]||document.documentElement;var B=document.createElement("script");B.src=C;B.type="text/javascript";var A=false;B.onload=B.onreadystatechange=function(){if(!A&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){A=true;if(typeof (F)=="function"){F(E)}D.removeChild(this)}};D.insertBefore(B,D.firstChild)}var js={get:function(A){return(typeof (A)=="string")?document.getElementById(A):A},elem:function(A){return this.get(A)?new this._elemClass(this,A):null},getByClass:function(A){return this.find(document.body,"*",A)},isDefined:function(A){return typeof (A)!="undefined"},isArray:function(A){return A.constructor==Array},isFunction:function(A){return typeof (A)=="function"},msie:(function(){var A=navigator.userAgent.toLowerCase();return/msie/.test(A)&&!/opera/.test(A)})(),trim:function(A){return A.replace(/(^\s*)|(\s*$)/g,"")},format:function(B){var B=arguments[0];for(var A=1;A<arguments.length;A++){B=B.replace(new RegExp("\\{"+(A-1)+"\\}","gm"),arguments[A])}return B},find:function(A,I,F,H,D){var B=new Array();var E=this.get(A).getElementsByTagName(I||"*");for(var C=0;C<E.length;C++){var G=this.elem(E[C]);if(F&&(G.object.className!=F&&!G.object.className.match(new RegExp("(^|\\s)"+F+"(\\s|$)")))){continue}if(H&&!D&&!G.attr(H)){continue}if(H&&D&&G.attr(H)!=D){continue}B.push(G.object)}return B},_elemClass:function(B,A){this.object=B.get(A);this.hide=function(){this.object.style.display="none";return this};this.show=function(){this.object.style.display="";return this};this.html=function(C){return B.isDefined(C)?(this.object.innerHTML=C,this):this.object.innerHTML};this.val=function(C){return B.isDefined(C)?(this.object.value=C,this):this.object.value};this.check=function(C){return B.isDefined(C)?(this.object.checked=C,this):this.object.checked};this.sel=function(C){return B.isDefined(C)?(this.object.selectIndex=C,this):(this.object.selectIndex==-1?null:this.object.options[this.object.selectIndex])};this.attr=function(C,D){return B.isDefined(D)?(this.object.setAttribute(C,D),this):this.object.getAttribute(C)};this.css=function(C,D){return B.isDefined(D)?(this.object.style[C]=D,this):this.object.style[C]};this.className=function(C){return B.isDefined(C)?(this.object.className=C,this):this.object.className};this.find=function(C,E,D,F){return B.find(this.object,C,E,D,F)}}};var quote_ex={init:function(A){window.QuoteData={};QuoteData.show_quote=function(){quote_ex._quoteLoadCallback()};if(!A){A={}}this.timeout=A["timeout"]||6000;this.add(A["codes"]);this.defaultCode=A["defaultCode"];this.fixedNum=A["fixedNum"]||2;this.quoteMark=A["quoteMark"]||"_quote_";this.util.cRed=A["red"]||"cRed";this.util.cGreen=A["green"]||"cGreen";this.refresh(A["autoAdd"]);this.init=function(){throw new Error("quote_ex has been initialized.")}},onQuoteLoading:null,onQuoteLoaded:null,onQuoteProcessing:null,onQuoteProcessed:null,onPageRender:null,onElementRender:null,_codes:null,defaultCode:null,timeout:null,timer:null,quoteMark:null,fixedNum:2,codeMap:{},quoteElementsMap:null,quoteDataMap:{},refresh:function(A){this._fillQuoteElemenetsMap();if(A!=false){this.addAll()}},_fillQuoteElemenetsMap:function(){var F=js.find(document.body,null,null,this.quoteMark,null);this.quoteElementsMap={};if(!F){return }for(var B=0;B<F.length;B++){var E=js.elem(F[B]);var D=E.attr("code")||this.defaultCode;if(!D){continue}var C=E.attr(this.quoteMark);if(!C){continue}var G=this.quoteElementsMap[D]||(this.quoteElementsMap[D]={});if(G[C]){if(!js.isArray(G[C])){var A=G[C];G[C]=[A]}G[C].push(F[B])}else{G[C]=F[B]}}},addAll:function(){this.clear();for(var A in this.quoteElementsMap){this.codeMap[A]=true}},add:function(C){if(!C){return }var A=js.isArray(C)?C:C.split(",");for(var B=0;B<A.length;B++){this.codeMap[A[B]]=true}this._codes=null},remove:function(C){if(!C){return }var A=js.isArray(C)?C:C.split(",");for(var B=0;B<A.length;B++){if(!this.codeMap[A[B]]){continue}this.codeMap[A[B]]=false}this._codes=null},clear:function(){this.codeMap={};this._codes=null},getCodes:function(){if(!this._codes){this._codes=[];for(var A in this.codeMap){if(this.codeMap[A]){this._codes.push(A)}}}return this._codes},_fillQuoteDataMap:function(){this.eachCode(function(code){try{var quoteStr=eval("quote_"+code);if(!quoteStr){return }var quoteData=quote_ex.quoteDataMap[code]||(quote_ex.quoteDataMap[code]={});quote_ex._fillQuoteData(quoteData,quoteStr)}catch(ex){}})},_fillQuoteData:function(K,F){var A=K;var L=F.split(";");if(L.length<32){return null}if(js.isFunction(this.onQuoteProcessing)){this.onQuoteProcessing(L,K,F)}A["quotestring"]=F;var B=L[0];var J=this.fixedNum;var E=(L[10]*1);var H=Number(L[2]);if(E==0){E=H}A["code"]=L[0];A["shortcode"]=L[0].substring(1);A["name"]=L[1];A["previousclose"]=H;A["openprice"]=(L[3]*1);A["shareamount"]=(L[4]/10000).toFixed(0);A["shareamount1"]=(L[4]/100000000).toFixed(0);A["sharevolume"]=(L[5]/100).toFixed(0);A["sharevolume1"]=(L[5]/10000).toFixed(0);A["sharecount"]=(L[6]*1).toFixed(0);A["updown"]=(L[7]*1);A["todayhigh"]=(L[8]*1);A["todaylow"]=(L[9]*1);A["pe"]=(L[11]*1);A["buyprice1"]=(L[12]*1).toFixed(J);A["buycount1"]=(L[13]/100).toFixed(0);A["buyprice2"]=(L[14]*1).toFixed(J);A["buycount2"]=(L[15]/100).toFixed(0);A["buyprice3"]=(L[16]*1).toFixed(J);A["buycount3"]=(L[17]/100).toFixed(0);A["buyprice4"]=(L[18]*1).toFixed(J);A["buycount4"]=(L[19]/100).toFixed(0);A["buyprice5"]=(L[20]*1).toFixed(J);A["buycount5"]=(L[21]/100).toFixed(0);A["sellprice1"]=(L[22]*1).toFixed(J);A["sellcount1"]=(L[23]/100).toFixed(0);A["sellprice2"]=(L[24]*1).toFixed(J);A["sellcount2"]=(L[25]/100).toFixed(0);A["sellprice3"]=(L[26]*1).toFixed(J);A["sellcount3"]=(L[27]/100).toFixed(0);A["sellprice4"]=(L[28]*1).toFixed(J);A["sellcount4"]=(L[29]/100).toFixed(0);A["sellprice5"]=(L[30]*1).toFixed(J);A["sellcount5"]=(L[31]/100).toFixed(0);A["time"]=L[32];var I=A["price"];if(!I){I=E}A["price"]=E;var D=E-I;if(E==0){A["updown"]=0;D=0}A["arrow"]=D>0?"¡ü":(D<0?"¡ý":"¡¡");A["trend"]=D;var C=(E-H);A["variable"]=C;var G=(C/H);A["percentnum"]=G;A["percent"]=(G*100).toFixed(2)+"%";A["updownarrow"]=C>0?"¡ü":(C<0?"¡ý":"¡¡");if(js.isFunction(this.onQuoteProcessed)){this.onQuoteProcessed(L,K,F)}},getQuoteData:function(A){return this.quoteDataMap[A]},getQuoteElement:function(A){return this.quoteElementsMap[A]},_quoteLoadCallback:function(){this._fillQuoteDataMap();if(js.isFunction(this.onQuoteLoading)){this.onQuoteLoading()}if(js.isFunction(this.onPageRender)){this.onPageRender()}else{this.defPageRender()}if(js.isFunction(this.onQuoteLoaded)){this.onQuoteLoaded()}},defPageRender:function(){this.eachElememt(function(A,C,B){if(js.isFunction(quote_ex.onElementRender)){quote_ex.onElementRender(A,C,B)}else{quote_ex.defElementRender(A,C,B)}})},colorNeedMap:{percent:true,arrow:true,updownarrow:true,price:true,variable:true,previousclose:true,openprice:true,updown:true,pe:true,todayhigh:true,todaylow:true,buyprice1:true,buyprice2:true,buyprice3:true,buyprice4:true,buyprice5:true,sellprice1:true,sellprice2:true,sellprice3:true,sellprice4:true,sellprice5:true,avg:true},toFixedNeedMap:{price:true,variable:true,previousclose:true,openprice:true,updown:true,pe:true,todayhigh:true,todaylow:true,avg:true},defElementRender:function(A,D,C){var B=js.elem(D);if(this.toFixedNeedMap[A]){B.html(C[A].toFixed(this.fixedNum))}else{B.html(C[A])}if(this.colorNeedMap[A]){B.className(B.className().replace(new RegExp("\\b("+this.util.cRed+")\\b|\\b("+this.util.cGreen+")\\b","g"),"")+" "+this.util.getUpDownColorCss(C["variable"]))}},eachCode:function(C){if(!js.isFunction(C)){throw new Error("invalid function")}var A=this.getCodes();for(var B=0;B<A.length;B++){C(A[B])}},eachQuoteData:function(A){if(!js.isFunction(A)){throw new Error("invalid function")}for(var B in this.quoteDataMap){A(B,this.getQuoteData(B))}},eachQuoteElement:function(A){this.eachQuoteData(function(B,C){A(B,C,quote_ex.getQuoteElement(B))})},eachElememt:function(A){this.eachQuoteElement(function(E,F,B){if(!B){return }for(var D in B){var G=B[D];if(js.isArray(G)){for(var C=0;C<G.length;C++){A(D,G[C],F)}}else{A(D,G,F)}}})},loadOnce:function(C){this.add(C);if(this.getCodes().length==0){return }var D=new Date();var A=""+D.getHours()+D.getMinutes()+D.getSeconds();if(this.getCodes().length<250||!js.msie){importJs("http://data.quotes.money.163.com/"+A+"?"+this.getCodes().join(";"))}else{for(var B=0;B<this.getCodes().length;B+=250){importJs("http://data.quotes.money.163.com/"+A+"?"+this.getCodes().slice(B,B+250).join(";"))}}},loadData:function(B){if(this.timer){window.clearTimeout(this.timer);this.timer=null}this.loadOnce(B);var A=(new Date()).getHours();this.timer=window.setTimeout(function(){quote_ex.loadData()},this.timeout)},util:{cRed:null,cGreen:null,getUpDownColorCss:function(A){return A>0?this.cRed:(A<0?this.cGreen:"")},wrapUpDownColor:function(A,B){return'<span class="'+this.getUpDownColorCss(A)+'">'+B+"</span>"},percentToNumber:function(A){return Number(A.replace("%",""))/100},formatPercent:function(A){return parseInt(A*10000)/100+"%"}}};