function $(a){if(document.getElementById){return document.getElementById(a)}else{return document.all.objName}}if(typeof $C=="undefined"){$C=function(a){return document.createElement(a)}}function oEvent(b){var b=b?b:(window.event?window.event:null);var a=(b.target)?b.target:b.srcElement;return(a)}function getEvent(){var a=window.event?window.event:getEvent.caller.arguments[0];return(a)}function addEvent(b,c,a){if(b.addEventListener){b.addEventListener(c,a,false)}else{if(b.attachEvent){b.attachEvent("on"+c,a)}else{b["on"+c]=a}}}String.prototype.trim=function(){return this.replace(/(^\s+)|(\s+$)/g,"")};Function.prototype.Bind=function(){var d=this,b=arguments[0],a=new Array();for(var c=1;c<arguments.length;c++){a.push(arguments[c])}return function(){return d.apply(b,a)}};Function.prototype.BindForEvent=function(){var d=this,b=arguments[0],a=new Array();for(var c=1;c<arguments.length;c++){a.push(arguments[c])}return function(e){return d.apply(b,[(e||window.event)].concat(a))}};var isIE=false;var userAgent=navigator.userAgent.toLowerCase();if((userAgent.indexOf("msie")!=-1)&&(userAgent.indexOf("opera")==-1)){isIE=true}var Nav=function(c){this.element=$("nav");var f=$C("table");f.className="table";f.cellPadding=0;f.cellSpacing=0;f.border=0;var b=f.insertRow(0);for(var d=0;d<c.length;d++){var a=b.insertCell(d);a.className=d==0?"index":"off";a.onmouseover=function(){this.className=this.className=="index"?"index":"on"};a.onmouseout=function(){this.className=this.className=="index"?"index":"off"};var e=$C("a");e.target="_blank";e.href=c[d][0];e.innerHTML=c[d][1];a.appendChild(e)}this.element.appendChild(f)};var TabSwitch=function(){this.Init.apply(this,arguments)};TabSwitch.prototype={Init:function(m,g,c,l){this.tabs=[];this.targets=[];var n=m.childNodes;var a=g.childNodes;for(var e=0;e<n.length;e++){if(n[e].nodeType==1){this.tabs.push(n[e])}}for(var d=0;d<a.length;d++){if(a[d].nodeType==1){this.targets.push(a[d])}}if(c){this.subTargets=[];var o=c.childNodes;for(var f=0;f<o.length;f++){if(o[f].nodeType==1){this.subTargets.push(o[f])}}this.activeSubTarget=this.subTargets[0]}if(l){for(var b=0;b<this.tabs.length;b++){this.tabs[b].onclick=this.showTab.BindForEvent(this,b,l[b])}}else{for(var b=0;b<this.tabs.length;b++){this.tabs[b].onclick=this.showTab.BindForEvent(this,b)}}this.activeTab=this.tabs[0];this.activeTarget=this.targets[0]},showTab:function(a,b,c){if(this.tabs[b]==this.activeTab){return}if(this.activeTab){this.activeTab.className=""}this.activeTab=this.tabs[b];this.activeTab.className="active";if(this.activeTarget){this.activeTarget.style.display="none"}this.activeTarget=this.targets[b];this.activeTarget.style.display="";if(this.subTargets){this.activeSubTarget.style.display="none";this.activeSubTarget=this.subTargets[b];this.activeSubTarget.style.display=""}if(c){this.activeCallback=c;c()}}};var __UP_COLOR="#008000";var __DOWN_COLOR="#F00";var __STABLE_COLOR="#000";function getColorCode(b,a){var b=parseFloat(b);if(a){b=0-b}if(b>0){return __UP_COLOR}else{if(b<0){return __DOWN_COLOR}else{return __STABLE_COLOR}}}function addSymbol(a){if(a*1>0){return["+",a].join("")}return a}function codeTrim(b){var a=/(sh|sz)/;return b.toString().replace(a,"")}var __SINAJS_URL="http://hq.sinajs.cn/list=";var __REALTIME_INDEXS="http://hq.sinajs.cn/?list=sh000001,sz399001,sh000011,sz399305";var __IF_URL="http://finance.sina.com.cn/futures/quote/cff/bc.shtml?code=__CODE__";var __FUTURE_URL="http://finance.sina.com.cn/money/future/quote.html?__CODE__";var FutureQuote={dataQuote:[],dataReal:[],Init:function(){this.sCode=window.CODE;this.scriptLoader();var a=window.setInterval(this.scriptLoader.Bind(this),30000)},scriptLoader:function(){var b=new IO.Script();var a=__SINAJS_URL+"hf_"+this.sCode;b.load(a,this.update.Bind(this))},tplReplace:function(c,e,b){for(var a=0;a<b.length;a++){var d=new RegExp(b[a][0],"g");e=e.replace(d,b[a][1])}c.innerHTML=e},colorRender:function(a,b){return'<span style="color:'+b+';">'+a+"</span>"},update:function(){this.dataQuote=[];var a=window["hq_str_hf_"+this.sCode].split(",");for(var b=0;b<a.length;b++){this.dataQuote.push(a[b]?a[b]:"--")}var c=getColorCode((this.dataQuote[0]-this.dataQuote[7]));this.tplReplace($("futureTitle"),this.titleTpl,[["@FUTURENAME@",window.CNAME],["@LAST_UPDATE_TIME@",this.dataQuote[12]+" "+this.dataQuote[6]],["@FUTURECODE@",this.sCode]]);this.tplReplace($("futureTbl"),this.futureTblTpl,[["@FUTURE_PRICE@",this.colorRender((this.dataQuote[0]*1).toFixed(2),c)],["@CHANGE@",this.colorRender(addSymbol((this.dataQuote[0]-this.dataQuote[7]).toFixed(2)),c)],["@CHANGE_RATE@",this.colorRender(addSymbol(((this.dataQuote[0]-this.dataQuote[7])/this.dataQuote[7]*100).toFixed(2))+"%",c)],["@OPEN_PRICE@",this.colorRender(this.dataQuote[8]*1,getColorCode(this.dataQuote[8]-this.dataQuote[7]))],["@HIGH_PRICE@",this.colorRender(this.dataQuote[4]*1,getColorCode(this.dataQuote[4]-this.dataQuote[7]))],["@LOW_PRICE@",this.colorRender(this.dataQuote[5]*1,getColorCode(this.dataQuote[5]-this.dataQuote[7]))],["@LAST_COUNT@",(this.dataQuote[7]*1).toFixed(2)],["@TOTALSHARE@",this.dataQuote[9]],["@BID@",(this.dataQuote[2]*1).toFixed(2)],["@ASK@",(this.dataQuote[3]*1).toFixed(2)],["@BIDSIZE@",this.dataQuote[10]],["@ASKSIZE@",this.dataQuote[11]]]);if(this.lastPrice!=this.dataQuote[3]||!this.lastPrice){this.lastPrice=this.dataQuote[3]}else{return}this._twinkle(0)},_twinkle:function(a){if(typeof a=="undefined"){a=0}if(a%2==0){$("current_quote_big").innerHTML=this.colorRender((this.dataQuote[0]*1).toFixed(2),getColorCode((this.dataQuote[0]-this.dataQuote[7])))}else{$("current_quote_big").innerHTML=(this.dataQuote[0]*1).toFixed(2)}if(a==4){return}a++;window.setTimeout(this._twinkle.Bind(this,a),300)},titleTpl:'<table class="head">				<tbody>					<tr><th><h1>@FUTURENAME@</h1>@FUTURECODE@</th><td>@LAST_UPDATE_TIME@</td></tr>				</tbody>				</table>',futureTblTpl:'<table>					<tbody>						<tr><th rowspan="3"><h2 id="current_quote_big">@FUTURE_PRICE@</h2><h5>@CHANGE@ (@CHANGE_RATE@)</h5></th><td style="width:110px;">最新价: @FUTURE_PRICE@</td><td style="width:110px;">涨跌额: @CHANGE@</td><td style="width:110px;">涨跌幅: @CHANGE_RATE@</td><td>开盘价: @OPEN_PRICE@</td></tr>						<tr><td>昨结算: @LAST_COUNT@</td><td>最高价: @HIGH_PRICE@</td><td>最低价: @LOW_PRICE@</td><td>持仓量: @TOTALSHARE@</td></tr>						<tr><td>买&nbsp;&nbsp;价: @BID@</td><td>卖&nbsp;&nbsp;价: @ASK@</td><td>买&nbsp;&nbsp;量: @BIDSIZE@</td><td>卖&nbsp;&nbsp;量: @ASKSIZE@</td></tr>					</tbody>					</table>'};var IMGAC=function(){this.Init.apply(this,arguments)};IMGAC.prototype={Init:function(c,b,a){this.imgSrc=c;this.target=b;if(a){this.interval=a}this._update()},_update:function(){this.tempImg=$C("IMG");this.tempImg.src=this.imgSrc+"?"+(new Date()).getTime();if(isIE){this.tempImg.onreadystatechange=this._append.Bind(this)}else{this.tempImg.onload=this._append.Bind(this)}this.tempImg.onerror=this._error.Bind(this);if(this.interval){window.setTimeout(this._update.Bind(this),this.interval)}},_append:function(){if(this.tempImg.onreadystatechange){if(this.tempImg.readyState!="loaded"&&this.tempImg.readyState!="complete"){return}}this.target.innerHTML="";this.target.appendChild(this.tempImg);this._clear()},_clear:function(){if(this.tempImg.onreadystatechange){this.tempImg.onreadystatechange=null}else{this.tempImg.onload=null}this.tempImg.onerror=null},_error:function(a){this.target.innerHTML=this.errorTpl},errorTpl:'<div style="height:250px; line-height:250px;">您所查看的图片不存在或目前不可用，请稍候刷新重试</div>'};var HfSearch={_url:"http://finance.sina.com.cn/money/future/quote_hf.html?",Init:function(){this.wrap=$("hf_list_wrap");this.btn=$("btnSearch");this.fillByArr();this.btn.onclick=this.toResult.Bind(this)},fillByArr:function(){var a=1;for(var b in window.HF_LIST){this.wrap.options[a]=new Option(window.HF_LIST[b],b);a++}},toResult:function(){if(this.wrap.selectedIndex!=0){window.open(this._url+this.wrap.value)}}};var RightTbls={apiUrl:"http://hq.sinajs.cn/list=",Init:function(){this.keyStock_wrap=$("key_stocks");this.futureOversea_wrap=$("futureOversea");this.key_ifs_wrap=$("key_ifs");this.KeyIfArr=[];this.relatedFuture=window.RLFUTURE;for(var c=0;c<this.relatedFuture.length;c++){this.KeyIfArr.push(this.relatedFuture[c][1])}var b=new IO.Script(),a=this.apiUrl+window.RLSTOCK.join(",")+","+this.ftOverseaArr[0].join(",")+","+this.KeyIfArr.join(",");b.load(a,this.trigger.Bind(this))},trigger:function(){this.fillKeyStocks();this.fillFtOversea();this.fillKeyIfs()},colorRender:function(a,b){if(a*1!=0){return'<span style="color:'+b+';">'+a+"</span>"}else{return"--"}},fillKeyStocks:function(){var f="<table><thead><tr><th>名称</th><th>最新价</th><th>涨跌幅</th></tr></thead><tbody>";var e=window.RLSTOCK.length>20?20:window.RLSTOCK.length;for(var b=0;b<e;b++){var c=window["hq_str_"+window.RLSTOCK[b]].split(",");var a=c[3]!=0?addSymbol(((c[3]-c[2])/c[2]*100).toFixed(2)):0;var d=getColorCode(a,true);f+=this.stockTrTpl.replace("@NAME@",c[0]).replace("@CODE@",window.RLSTOCK[b]).replace("@PRICE@",this.colorRender(c[3],d)).replace("@CHANGERATE@",this.colorRender(a+"%",d))}f+="</tbody></table>";this.keyStock_wrap.innerHTML=f},fillFtOversea:function(){var f="<table><thead><tr><th>名称</th><th>最新价</th><th>涨跌额</th></tr></thead><tbody>";for(var c=0;c<this.ftOverseaArr[0].length;c++){var d=window["hq_str_"+this.ftOverseaArr[0][c]].split(",");var a=(d[0]-d[7])!=0?((d[0]-d[7])>0?"+":"-"):"";var e=getColorCode(d[0]-d[7]);var b=this.ftOverseaArr[0][c].replace("hf_","");f+=this.ftOverseaTpl.replace("@NAME@",this.ftOverseaArr[1][c]).replace("@CODE@",b).replace("@PRICE@",this.colorRender((d[0]*1).toFixed(2),e)).replace("@CHANGE@",this.colorRender(a+(d[1]*1).toFixed(2),e))}f+="</tbody></table>";this.futureOversea_wrap.innerHTML=f},fillKeyIfs:function(){var e="<table><thead><tr><th>名称</th><th>最新价</th><th>涨跌额</th></tr></thead><tbody>";for(var a=0;a<this.KeyIfArr.length;a++){if(window["hq_str_"+this.KeyIfArr[a]]!=""){var b=window["hq_str_"+this.KeyIfArr[a]].split(",");var d=b[8]*1!=0?addSymbol((b[8]-b[10]).toFixed(2)):0;var c=getColorCode(d,true);e+=this.keyIfsTpl.replace("@NAME@",this.relatedFuture[a][0]).replace("@CODE@",this.relatedFuture[a][1]).replace("@PRICE@",this.colorRender(b[8]*1,c)).replace("@CHANGE@",this.colorRender(d,c))}else{e+=this.keyIfsTpl.replace("@NAME@",this.relatedFuture[a][0]).replace("@CODE@",this.relatedFuture[a][1]).replace("@PRICE@","--").replace("@CHANGE@","--")}}e+="</tbody></table>";this.key_ifs_wrap.innerHTML=e},stockTrTpl:'<tr><th><a href="http://finance.sina.com.cn/realstock/company/@CODE@/nc.shtml" target="_blank">@NAME@</a></th><td>@PRICE@</td><td>@CHANGERATE@</td></tr>',ftOverseaArr:[["hf_S","hf_C","hf_TRB","hf_SB","hf_CAD","hf_ZSD","hf_AHD","hf_CL","hf_GC","hf_SI"],["美黄豆","美玉米","日本橡胶","NYBOT-11糖","LME3月铜","LME3月锌","LME3月铝","原油","黄金","白银"]],ftOverseaTpl:'<tr><th><a href="http://finance.sina.com.cn/money/future/quote_hf.html?@CODE@" target="_blank">@NAME@</a></th><td>@PRICE@</td><td>@CHANGE@</td></tr>',keyIfsTpl:'<tr><th><a href="http://finance.sina.com.cn/money/future/quote.html?@CODE@" target="_blank">@NAME@</a></th><td>@PRICE@</td><td>@CHANGE@</td></tr>'};function main(){window.nav=new Nav([["http://finance.sina.com.cn/","财经首页"],["http://finance.sina.com.cn/futuremarket/","期货首页"],["http://finance.sina.com.cn/stock/indexfuture/","股指期货"],["http://finance.sina.com.cn/futuremarket/yspzx.html","期指资讯"],["http://finance.sina.com.cn/futuremarket/gold.html","黄金"],["http://finance.sina.com.cn/column/futuresnyzx.html","能源"],["http://finance.sina.com.cn/futuremarket/indu.html","工业品"],["http://finance.sina.com.cn/futuremarket/agri.html","农产品"],["http://q.blog.sina.com.cn/qihuoblog/","期货圈"],["http://bar.sina.com.cn/bar.php?name=%C6%DA%BB%F5","期货吧"],["http://biz.finance.sina.com.cn/hq/","行情中心"],["http://vip.stock.finance.sina.com.cn/portfolio/main.php","自选股"]]);FutureQuote.Init();window.quoteImg=new IMGAC("http://image.sinajs.cn/newchart/v5/futures/global/min/@CODE@.gif".replace("@CODE@",window.CODE),$("hqimg_1"),30000);HfSearch.Init();RightTbls.Init()};