function $(a){if(document.getElementById){return document.getElementById(a)}else{return document.all.objName}}function $C(a){return document.createElement(a)}function oEvent(){var b=window.event?window.event:oEvent.caller.arguments[0];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.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._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(){var f=[];for(var e=0;e<arguments.length;e++){f.push(arguments[e])}return d.apply(b,f.concat(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))}};function Colorize(b,a){if(a*1>0){return['<span style="color:#008000;">',b,"</span>"].join("")}else{if(a*1<0){return['<span style="color:#f00;">',b,"</span>"].join("")}}return b}String.prototype.trim=function(){return this.replace(/(^\s+)|(\s+$)/g,"")};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 ImgController={imageArr:[],Init:function(){var f=HKQuoteParams.getParam("code");if(HKQuoteParams.isIrregular()){f=HKQuoteParams.getParam("original_code")}for(var b=0;b<this.imgSrc.length;b++){this.imgSrc[b]=this.imgSrc[b].replace("{!--CODE--}",f)}this.kLineController.kBasicSrc=this.kLineController.kBasicSrc.replace("{!--CODE--}",f);var a=[];var e=$("tagetImg").childNodes;var d=0;for(var c=0;c<e.length;c++){if(e[c].nodeType==1){a.push(e[c]);this.elementAppend(a[d],d);d++}}this.imgInterval=window.setInterval("ImgController.imageArr[0].src = ImgController.imgSrc[0] + '?' + (new Date()).getTime()",60000)},elementAppend:function(a,b){this.imageArr[b]=new Image();this.imageArr[b].src=this.imgSrc[b]+"?"+(new Date()).getTime();a.innerHTML="";a.appendChild(ImgController.imageArr[b])},imgSrc:["http://image.sinajs.cn/newchart/hk_stock/min/{!--CODE--}.gif","http://image.sinajs.cn/newchart/hk_stock/daily/{!--CODE--}.gif","http://image.sinajs.cn/newchart/hk_stock/weekly/{!--CODE--}.gif","http://image.sinajs.cn/newchart/hk_stock/monthly/{!--CODE--}.gif"],kLineController:{kTabSeries:{kDay:[],kWeek:[],kMonth:[]},kBasicSrc:"http://image.sinajs.cn/newchart/hk_kline/{!--CODE--}_{!--TYPE--}.gif",Init:function(b,c){var a=$C("DIV");switch(c){case 1:a.innerHTML=this.kModule.kDay;b.appendChild(a);this.kTabInit("kDay",1);break;case 2:a.innerHTML=this.kModule.kWeek;b.appendChild(a);this.kTabInit("kWeek",2);break;case 3:a.innerHTML=this.kModule.kMonth;b.appendChild(a);this.kTabInit("kMonth",3);break}},kTabInit:function(e,b){var a=$(e).childNodes;var d=0;for(var c=0;c<a.length;c++){if(a[c].nodeType==1){this.kTabSeries[e].push(a[c]);this.kTabSeries[e][d].onclick=this.kTabSwitch.BindForEvent(this,this.kTabSeries[e][d],e,b,d);d++}}},kTabSwitch:function(f,e,g,b,a){if(e.className=="active"){return}var c=this.kTabSeries[g];for(var d=0;d<c.length;d++){c[d].className=""}e.className="active";ImgController.imageArr[b].src=this.kBasicSrc.replace("{!--TYPE--}",this.kImgType[g][a])},kImgType:{kDay:["1m_day","3m_day","6m_day","1y_day"],kWeek:["6m_week","1y_week","3y_week","5y_week"],kMonth:["3y_month","5y_month","10y_month"]},kModule:{kDay:'<ul id="kDay"><li class="active">一月</li><li>三月</li><li>六月</li><li>一年</li></ul><span>时间长度：</span>',kWeek:'<ul id="kWeek"><li class="active">六月</li><li>一年</li><li>三年</li><li>五年</li></ul><span>时间长度：</span>',kMonth:'<ul id="kMonth"><li class="active">三年</li><li>五年</li><li>十年</li></ul><span>时间长度：</span>'}}};var TabSwitch=function(){this.Init.apply(this,arguments)};TabSwitch.prototype={Init:function(e,a,h){this.tabs=[];this.targets=[];var f=e.childNodes;var g=a.childNodes;for(var d=0;d<f.length;d++){if(f[d].nodeType==1){this.tabs.push(f[d])}}for(var c=0;c<g.length;c++){if(g[c].nodeType==1){this.targets.push(g[c])}}for(var b=0;b<this.tabs.length;b++){this.tabs[b].onclick=this.showTab.BindForEvent(this,this.tabs[b],this.targets[b])}this.activeTab=this.tabs[0];this.activeTarget=this.targets[0]},showTab:function(b,a,c){if(a==this.activeTab){return}if(this.activeTab){this.activeTab.className=""}this.activeTab=a;this.activeTab.className="active";if(this.activeTarget){this.activeTarget.style.display="none"}this.activeTarget=c;this.activeTarget.style.display=""}};var HkSearch=function(){this.Init.apply(this,arguments)};HkSearch.prototype={Init:function(a,b){this.button=a;this.textInput=b;this.button.onclick=this.searchStart.BindForEvent(this);this.textInput.onkeydown=this.textInputEnter.BindForEvent(this);this.textInput.onfocus=this.textInputFocus.BindForEvent(this);this.textInput.onblur=this.textInputBlur.BindForEvent(this)},searchStart:function(){var b=this.textInput.value;var a=/^[0-9]{1,4}$/;if(a.test(b)==false){return}window.open("http://biz.finance.sina.com.cn/hk/quote.php?code="+b)},textInputEnter:function(){var a=getEvent();if(a.keyCode==13){this.searchStart()}},textInputFocus:function(){var a=this.textInput.value;if(a=="请输入港股代码"){this.textInput.value=""}},textInputBlur:function(){var a=this.textInput.value;if(a==""){this.textInput.value="请输入港股代码"}}};var Cookie=function(){this.Init.apply(this,arguments)};Cookie.prototype={_items:{},_nItems:0,Init:function(){},_init:function(){if(document.cookie.length==0){return}var b=document.cookie.split(";");var a;this._nItems=b.length;if(this._nItems==0){return}for(var c=0;c<this._nItems;c++){a=b[c].split("=");if(a.length!=2){continue}this._items[a[0].trim()]=a[1].trim()}},get:function(a){this._init();if(typeof this._items[a]!="undefined"){return unescape(this._items[a])}return""},set:function(c,e,a,g,d,f){if(typeof c=="undefined"){return false}if(typeof e=="undefined"){return false}var b=c+"="+escape(e)+"; ";if(typeof a!="undefined"){b+="expires="+a+"; "}if(typeof g!="undefined"){b+="path="+g+"; "}if(typeof d!="undefined"){b+="domain="+d+"; "}if(f==true){b+="secure;"}document.cookie=b},remove:function(a){document.cookie=a+"=; expires=Fri, 21 Dec 1976 04:31:24 GMT;"},getCount:function(){this._init();return this._nItems}};var __UP_COLOR="#008000";var __DOWN_COLOR="#F00";var __STABLE_COLOR="#000";function getColorCode(a){a=parseFloat(a);if(a>0){return __UP_COLOR}else{if(a<0){return __DOWN_COLOR}else{return __STABLE_COLOR}}}var HK_INDEX_OLD2NEW={"5001":"HSI","5002":"HSI_FIN","5003":"HSI_UTL","5004":"HSI_PRO","5005":"HSI_CNI","5006":"HSCCI","5007":"HSCEI","5008":"HSHKCI","5009":"HSCI","5020":"GEM","5022":"SPHKL","5024":"HSHKMI","5026":"HSHKSI","5027":"HSMCI","5028":"HSHKLI","5029":"FXI_CHINA","5030":"HSCHFI","5051":"HSIF_SPOT","5052":"HSIF_NEXT","5053":"FXCF_SPOT","5054":"FXCF_NEXT","5055":"HSHFI_SPOT","5056":"HSHFI_NEXT"};var HK_INDEX_NEW2OLD={HSI:"5001",HSI_FIN:"5002",HSI_UTL:"5003",HSI_PRO:"5004",HSI_CNI:"5005",HSCCI:"5006",HSCEI:"5007",HSHKCI:"5008",HSCI:"5009",GEM:"5020",SPHKL:"5022",HSHKMI:"5024",HSHKSI:"5026",HSMCI:"5027",HSHKLI:"5028",FXI_CHINA:"5029",HSCHFI:"5030",HSIF_SPOT:"5051",HSIF_NEXT:"5052",FXCF_SPOT:"5053",FXCF_NEXT:"5054",HSHFI_SPOT:"5055",HSHFI_NEXT:"5056"};var HK_INDEX_IRREGULAR={"HSI-FIN":"HSI_FIN","HSI-UTL":"HSI_UTL","HSI-PRO":"HSI_PRO","HSI-CNI":"HSI_CNI"};var HK_INDEX_IRREGULAR_ORIGINAL={HSI_FIN:"HSI-FIN",HSI_UTL:"HSI-UTL",HSI_PRO:"HSI-PRO",HSI_CNI:"HSI-CNI"};var __HK_VISITED_STOCKS_COOKIE_NAME="hk_visited_stocks";var __HK_VISITED_STOCKS_NUM=17;var __SINAJS_URL="http://hq.sinajs.cn/?rn=@RN@&list=";var __HK_COMPANY_INFO_URL="http://money.finance.sina.com.cn/q/view/vHK_StockInfoOneJs.php";var G_REALTIME_INDEXS="http://hq.sinajs.cn/?list=hkHSI,hkHSCCI,hkHSCEI";var G_TOPTEN_URL="http://biz.finance.sina.com.cn/hk/topten_api/TopTen.php";var SinajsQuoteParser={parse:function(b){var a=window["hq_str_"+b];if(typeof a=="undefined"){return null}if(a.length==0){return null}return a.split(",")}};var HKQuoteParams={_params:null,_isIndex:false,_isIrregular:false,_checkIsIndex:function(a){if(typeof HK_INDEX_NEW2OLD[a]!="undefined"){return true}if(typeof HK_INDEX_OLD2NEW[a]!="undefined"){return true}if(typeof HK_INDEX_IRREGULAR[a]!="undefined"){return true}return false},_checkIsIrregular:function(b){var a=this._parseIndexCode(b);if(typeof a.original_code!="undefined"){return true}return false},_parseIndexCode:function(c){var a={};var b=/\d{4}/;if(b.test(c)){a.old_code=c;if(typeof HK_INDEX_OLD2NEW[c]!="undefined"){a.code=HK_INDEX_OLD2NEW[c]}else{return false}if(typeof HK_INDEX_IRREGULAR_ORIGINAL[a.code]!="undefined"){a.original_code=HK_INDEX_IRREGULAR_ORIGINAL[a.code]}return a}if(typeof HK_INDEX_IRREGULAR[c]!="undefined"){a.original_code=c;a.code=HK_INDEX_IRREGULAR[c];a.old_code=HK_INDEX_NEW2OLD[a.code];return a}if(typeof HK_INDEX_IRREGULAR_ORIGINAL[c]!="undefined"){a.code=c;a.old_code=HK_INDEX_NEW2OLD[c];a.original_code=HK_INDEX_IRREGULAR_ORIGINAL[c];return a}if(typeof HK_INDEX_NEW2OLD[c]!="undefined"){a.code=c;a.old_code=HK_INDEX_NEW2OLD[c];return a}return false},getParams:function(){if(this._params!=null){return this._params}var f={};var h=window.location.search.replace("?","");var a=h.split("&");var g=a.length;var e=[];for(var d=0;d<g;d++){e=a[d].split("=");if(e.length==2){f[e[0]]=e[1]}}if(this._checkIsIndex(f.code)){this._isIndex=true;if(this._checkIsIrregular(f.code)){this._isIrregular=true}var c=this._parseIndexCode(f.code);for(var b in c){f[b]=c[b]}}if(typeof f.code!="undefined"){f.code=f.code.replace(/[^0-9a-z_]/ig,"_")}if(/^\d{1,4}$/.test(f.code)){f.code=("0000"+f.code).slice(-5)}if(f.code.indexOf("hk")!=-1){f.code=f.code.replace("hk","")}this._params=f;return f},getParam:function(a){if(this._params!=null){return this._params[a]}return this.getParams()[a]},getParam4:function(){if(this._params.code_4){return this._params.code_4}if(/^\d*$/.test(this.getParam("code"))){this._params.code_4=("000"+this.getParam("code")).slice(-4);return this._params.code_4}else{return this.getParam("code")}},isIndex:function(){if(this._params!=null){this.getParams()}return this._isIndex},isIrregular:function(){if(this._params!=null){this.getParams()}return this._isIrregular}};var GetTime={_sUrl:"http://counter.sina.com.cn/time?fm=JS",turnzero:false,Init:function(){var b=new IO.Script();b.load(this._sUrl,this._getTime.Bind(this));var d=HKQuoteParams.getParam("code");var a=__SINAJS_URL.replace("@RN@",(new Date()).getTime())+"hk"+d+"_i";var c=new IO.Script();c.load(a,this._getStatus.Bind(this,d))},_getTime:function(){this.bjDate=new Date(window.StandardBJTime*1000);var b=this.bjDate.getHours();var a=this.bjDate.getDay();if(a!=6&&a!=0){if(b<10&&b>6){this.turnzero=true}}if(this._ready){HKQuote.update(this._status)}else{this._ready=true}},_getStatus:function(a){this._status=window["hq_str_hk@C@_i".replace("@C@",a)].split(",")[6];if(this._ready){HKQuote.update(this._status)}else{this._ready=true}}};var HKQuote={_quote:{},_getQuoteAreaTpl:function(){return'<table class="head"><tbody><tr><th><h1>{#CHINA_NAME#}</h1>{#CODE#}.HK ({#ENGLISH_NAME#})</th><td>{#LAST_UPDATE_DATE#} {#LAST_UPDATE_TIME#}</td></tr></tbody></table>			<table><tbody>				<tr><th rowspan="3"><h5 id="current_quote_big">{#CURRENT#}</h5>{#CHANGE#} {#CHANGE_RATE#}</th><td>昨收盘:{#LAST_CLOSE#}</td><td>今开盘:{#OPEN#}</td><td>最高价:{#HIGH#}</td><td>最低价:{#LOW#}</td></tr>				<tr><td>成交额:{#VOLUME#}</td><td>成交量:{#TURNOVER#}</td><td>买入价:{#BUY#}</td><td>卖出价:{#SELL#}</td></tr>				<tr><td>市盈率:{#PE#}</td><td>收益率:{#YIELD#}</td><td>52周最高:{#52W_HIGH#}</td><td>52周最低:{#52W_LOW#}</td></tr>			</tbody></table>'},_getIndexAreaTpl:function(){return'<table class="head head_index"><tbody><tr><th><h1>{#CHINA_NAME#}</h1></th><td>{#LAST_UPDATE_DATE#} {#LAST_UPDATE_TIME#}</td></tr></tbody></table>			<table class="index"><tbody>				<tr><th rowspan="2"><h5 id="current_quote_big">{#CURRENT#}</h5>{#CHANGE#} {#CHANGE_RATE#}</th><td>昨收盘:{#LAST_CLOSE#}</td><td>今开盘:{#OPEN#}</td><td>最高价:{#HIGH#}</td><td>最低价:{#LOW#}</td></tr>				<tr><td>成交额:{#VOLUME#}</td><td>52周最高:{#52W_HIGH#}</td><td>52周最低:{#52W_LOW#}</td><td>&nbsp;</td></tr>			</tbody></table>'},_updateQuoteArea:function(){var c=null;var e="";var d="";if(HKQuoteParams.isIndex()){d=this._getIndexAreaTpl();$("company_info_table").parentNode.parentNode.className+=" nav_index"}else{d=this._getQuoteAreaTpl()}for(var b in this._quote){c=new RegExp("{#"+b.toUpperCase()+"#}","g");switch(b){case"current":if(this._quote.change_rate!="停牌"){e=this._quote[b]}else{e="停牌"}break;case"change":e=HKStockFormatter.formatCommon(this._quote[b]>0?"+"+this._quote[b]:this._quote[b],this._quote.change);break;case"current":e=HKStockFormatter.formatCommon(this._quote[b],this._quote.change);break;case"change_rate":if(this._quote[b]!="停牌"){e="("+HKStockFormatter.formatCommon(this._quote[b]>0?"+"+this._quote[b]:this._quote[b],this._quote.change,"%")+")"}else{e=this._quote.current}break;case"volume":if(!HKQuoteParams.isIndex()){var a=this._quote[b]*1;if(a>100000000){e=(a/100000000).toFixed(2)+"亿元"}else{if(a>10000){e=(a/10000).toFixed(2)+"万元"}else{e=a+"元"}}}else{var a=this._quote[b]*1;e=(a/100000).toFixed(2)+"亿元"}break;case"turnover":var a=this._quote[b]*1;if(a>100000000){e=(a/100000000).toFixed(2)+"亿股"}else{if(a>10000){e=(a/10000).toFixed(2)+"万股"}else{e=a+"股"}}break;case"low":case"buy":case"sell":case"52w_high":case"52w_low":e=HKStockFormatter.formatCommon(this._quote[b],this._quote[b]-this._quote.last_close);break;default:e=this._quote[b];break}d=d.replace(c,e)}$("quote_area").innerHTML=d;if(this._quote.change_rate!="停牌"){this._twinkle(0)}},_twinkle:function(a){if(typeof a=="undefined"){a=0}if(a%2==0){$("current_quote_big").innerHTML=HKStockFormatter.formatCommon(this._quote.current,this._quote.change)}else{$("current_quote_big").innerHTML=this._quote.current}if(a==4){return}a++;window.setTimeout(this._twinkle.Bind(this,a),300)},_onQuoteDataLoaded:function(){var c=SinajsQuoteParser.parse("hk"+this._quote.code);if(c==null){PageDisplayController.showNoStockMessage();return}if(GetTime.turnzero){if(this._last_quote){GetTime.turnzero=this._last_quote==c.join(",")?true:false}else{this._last_quote=c.join(",")}}AHctrl.Init(c[6]);var b=new VisitedStocks();b.set(this._quote.code);if(this._stopstatus==1){this._quote.change="";this._quote.change_rate="停牌"}else{if(GetTime.turnzero){this._quote.change="0.00";this._quote.change_rate="0.00"}else{this._quote.change=c[7]?c[7]:"0.00";this._quote.change_rate=c[8]?c[8]:"0.00"}}this._quote.current=c[6]?c[6]:"0.00";this._quote.english_name=c[0]?c[0]:("HK."+this._quote.code);this._quote.china_name=c[1]?c[1]:this._quote.english_name;this._quote.open=c[2]?c[2]:"0.00";this._quote.last_close=c[3]?c[3]:"0.00";this._quote.high=c[4]?c[4]:"0.00";this._quote.low=c[5]?c[5]:"0.00";this._quote.buy=c[9]?c[9]:"0.00";this._quote.sell=c[10]?c[10]:"0.00";this._quote.volume=c[11]?c[11]:"0.00";this._quote.turnover=c[12]?c[12]:"0.00";this._quote.PE=c[13]?c[13]:"0.00";this._quote.yield=c[14]?c[14]:"0.00";this._quote["52w_high"]=c[15]?c[15]:"0.00";this._quote["52w_low"]=c[16]?c[16]:"0.00";var a=c[17]?c[17].substr(5).replace("/","-"):"00-00";this._quote.last_update_date=a;var d=c[18]?(c[18]+":00"):"00:00:00";this._quote.last_update_time=d;this._updateQuoteArea();document.title=this._quote.china_name+"("+this._quote.code+".HK)_港股_财经纵横_新浪网"},update:function(a){if(a){this._stopstatus=a}var d=HKQuoteParams.getParam("code");this._quote.code=d;var b=__SINAJS_URL.replace("@RN@",(new Date()).getTime())+"hk"+d;var c=new IO.Script();c.load(b,this._onQuoteDataLoaded.Bind(this))}};var HKStockFormatter={formatTitle:function(b,a,c){if(typeof c=="undefined"){c=a.length}if(a.length==0){a=b+".HK";c=a.length}return'<a href="http://finance.sina.com.cn/stock/hkstock/quote.html?code='+b+'" target="_blank" title="'+a+'">'+a.substr(0,c)+"</a>"},formatCurValue:function(a){return'<span style="color:'+getColorCode(a[8])+'">'+a[6]+"</span>"},formatChangeRate:function(b){var a=b[8]>0?"+"+b[8]:b[8];return'<span style="color:'+getColorCode(b[8])+'">'+a+"%</span>"},formatCommon:function(b,a,c){c=(typeof c=="undefined")?"":c;return'<span style="color:'+getColorCode(a)+'">'+b+c+"</span>"}};var VisitedStocks=function(){this.Init.apply(this,arguments)};VisitedStocks.prototype={_stocks:[],_cookie:null,Init:function(){this._cookie=new Cookie();var a=this._cookie.get(__HK_VISITED_STOCKS_COOKIE_NAME);if(a.length!=0){this._stocks=a.split("|")}var c=this._stocks.length;for(var b=0;b<c;b++){if(this._stocks[b].indexOf("-")!=-1){this._stocks[b]=this._stocks[b].replace("-","_")}}},_findStock:function(b){var c=this._stocks.length;for(var a=0;a<c;a++){if(this._stocks[a]==b){return a}}return -1},set:function(a){var b=this._findStock(a);if(b!=-1){this._stocks.splice(b,1)}this._stocks.unshift(a);if(this._stocks.length>__HK_VISITED_STOCKS_NUM){this._stocks.pop()}this._cookie.set(__HK_VISITED_STOCKS_COOKIE_NAME,this._stocks.join("|"),"Fri, 31 Dec 2099 23:59:59 GMT","/","finance.sina.com.cn")},getAll:function(){return this._stocks},clear:function(){this._cookie.remove(__HK_VISITED_STOCKS_COOKIE_NAME)}};var VisitedStocksTable={_hotStockList:["00941","03988","00001","02628","00005","01398","00857","03328","02318","00762","00008"],_getVisitedStocksTpl:function(){return"<table><thead><tr><th>名称</th><th>最新价</th><th>涨跌幅</th></tr>			</thead><tbody>{#CONTENTS#}</tbody></table>"},_getStockItemTpl:function(a){return"<tr><th>{#TITLE#}</th><td>{#PRICE#}</td><td>{#CHANGE_RATE#}</td></tr>"},_getHotStocksTpl:function(){return'<table><thead><tr><th colspan="3">以下为热门股票</th></tr></thead>				<tbody>{#CONTENTS#}</tbody></table>'},_getVisitedStocks:function(){var a=new VisitedStocks();return a.getAll()},_generateTable:function(f,m){var e="";var g=f.length;var b=m.length;var c=[];var a="";var d="";var o="";var n=[];for(var h=0;h<g;h++){d=f[h];c=SinajsQuoteParser.parse("hk"+d);if(c==null){continue}o=this._getStockItemTpl();if(d!=386){o=o.replace(/\{#TITLE#\}/,HKStockFormatter.formatTitle(d,c[1],4))}else{if(d==386){o=o.replace(/\{#TITLE#\}/,HKStockFormatter.formatTitle("0386","中国石化"))}}o=o.replace(/\{#PRICE#\}/,HKStockFormatter.formatCurValue(c));o=o.replace(/\{#CHANGE_RATE#\}/,HKStockFormatter.formatChangeRate(c));n.push(o)}var k=[];for(var h=0;h<b;h++){d=m[h];c=SinajsQuoteParser.parse("hk"+d);if(c==null){continue}o=this._getStockItemTpl();o=o.replace(/\{#TITLE#\}/,HKStockFormatter.formatTitle(d,c[1],4));o=o.replace(/\{#PRICE#\}/,HKStockFormatter.formatCurValue(c));o=o.replace(/\{#CHANGE_RATE#\}/,HKStockFormatter.formatChangeRate(c));k.push(o)}var l="";if(n.length!=0){l=this._getVisitedStocksTpl();l=l.replace(/\{#CONTENTS#\}/,n.join(""))}var j="";if(k.length!=0){j=this._getHotStocksTpl();j=j.replace(/\{#CONTENTS#\}/,k.join(""))}return l+j},_show:function(b,a){$("visited_stocks_tbl").innerHTML=this._generateTable(b,a)},show:function(){var g=this._getVisitedStocks();var c=g.length;var b=0;var a=[];if(c<__HK_VISITED_STOCKS_NUM){b=__HK_VISITED_STOCKS_NUM-c;a=this._hotStockList.slice(0,b-1)}var f=g.concat(a);var e="hk"+f.join(",hk");var d=new IO.Script();d.load(__SINAJS_URL.replace("@RN@",(new Date()).getTime())+e,this._show.Bind(this,g,a))}};var RelatedNewsIframe={_inited:false,_resize:function(a){},show:function(){var b=HKQuoteParams.getParam("code");if(HKQuoteParams.isIndex()){b=HKQuoteParams.getParam("old_code")}if(b==null){return}var a=$("related_news_iframe");if(!this._inited){a.src="http://biz.finance.sina.com.cn/hk/hk_page_iframe/related_news.php?code="+b;this._inited=true;a.onload=function(){var c=$("related_news_iframe");var d=c.contentWindow.document;var e=d.getElementById("related_news_items").childNodes.length;if(e<1){$("news_hkmarket").style.display=""}else{if(e<=5){$("news_singlestock").style.display="";$("news_hkmarket").style.display=""}else{$("news_singlestock").style.display=""}}c.style.width=d.getElementById("related_news_container").clientWidth+"px";c.style.height=d.getElementById("related_news_container").clientHeight+"px"};return}}};var CompanyInfoTable={linkTpl:'<a href="@URL@" target="_blank" title="@URL@">@TEXT@</a>',_show:function(d){var f=window["hk_company_info_"+d];if(typeof f=="undefined"){return}for(var b in f){if(!$("info_"+b)){continue}if(b!="Website"){$("info_"+b).innerHTML=f[b]?f[b]:""}else{var a=f[b].length<23?f[b]:f[b].substring(0,22)+"..";var e=f[b].split(",");var c=e[0].indexOf("http://")==-1?"http://"+e[0]:e[0];$("info_Website").innerHTML=this.linkTpl.replace(/@URL@/g,c).replace("@TEXT@",a)}}$("company_info_table").style.display=""},show:function(){var b=HKQuoteParams.getParam("code");if(b==null){return}var a=new IO.Script();a.load(__HK_COMPANY_INFO_URL+"?type=info&code="+b,this._show.Bind(this,b))}};var IncomingStatementTable={_sheets:[],_getNonBankSheetTpl:function(){return'<table><tbody>			<tr><th>营业额:</th><td>{#ITEMS0#}</td></tr>			<tr><th>除税前盈利/(亏损):</th><td>{#ITEMS1#}</td></tr>			<tr><th>税项:</th><td>{#ITEMS2#}</td></tr>			<tr><th>除税后盈利/(亏损):</th><td>{#ITEMS3#}</td></tr>			<tr><th>少数股东权益:</th><td>{#ITEMS4#}</td></tr>			<tr><th>股东应占盈利/(亏损):</th><td>{#ITEMS5#}</td></tr>			<tr><th>股息:</th><td>{#ITEMS6#}</td></tr>			<tr><th>除税及股息后盈利/(亏损):</th><td>{#ITEMS7#}</td></tr>			<tr><th>基本:</th><td>{#ITEMS8#}</td></tr>			<tr><th>摊薄:</th><td>{#ITEMS9#}</td></tr>			<tr><td colspan="2">{#CURRENCY#}{#UNITS#}</td></tr>		</tbody></table>'},_getBankSheetTpl:function(){return'<table><tbody>			<tr><th>利息收入:</th><td>{#ITEMS0#}</td></tr>			<tr><th>利息支出:</th><td>{#ITEMS1#}</td></tr>			<tr><th>净利息收入:</th><td>{#ITEMS2#}</td></tr>			<tr><th>其他经营收入:</th><td>{#ITEMS3#}</td></tr>			<tr><th>经营收入:</th><td>{#ITEMS4#}</td></tr>			<tr><th>经营支出:</th><td>{#ITEMS5#}</td></tr>			<tr><th>总准备:</th><td>{#ITEMS6#}</td></tr>			<tr><th>其他盈利/(亏损):</th><td>{#ITEMS7#}</td></tr>			<tr><th>除税前盈利/(亏损):</th><td>{#ITEMS8#}</td></tr>			<tr><th>税项:</th><td>{#ITEMS9#}</td></tr>			<tr><th>除税后盈利/(亏损):</th><td>{#ITEMS10#}</td></tr>			<tr><th>少数股东权益:</th><td>{#ITEMS11#}</td></tr>			<tr><th>股东应占盈利/(亏损):</th><td>{#ITEMS12#}</td></tr>			<tr><th>股息:</th><td>{#ITEMS13#}</td></tr>			<tr><th>除税及股息后盈利/(亏损):</th><td>{#ITEMS14#}</td></tr>			<tr><th>基本:</th><td>{#ITEMS15#}</td></tr>			<tr><th>摊薄:</th><td>{#ITEMS16#}</td></tr>			<tr><td colspan="2">{#CURRENCY#}{#UNITS#}</td></tr>		</tbody></table>'},_showTable:function(b){var d="";var c=null;if(typeof b=="undefined"){return}if(b.Type.toLowerCase()=="bank"){d=this._getBankSheetTpl()}else{d=this._getNonBankSheetTpl()}for(var a in b){c=new RegExp("{#"+a.toUpperCase()+"#}","g");d=d.replace(c,(b[a]?b[a]:"--"))}$("incoming_statement_sheet").innerHTML=d},_switchDropDown:function(){var a=this._sheets[$("incoming_statement_years").value];this._showTable(a)},_showDropDown:function(d){var e=$("incoming_statement_years");var a=d.length;var c=null;for(var b=0;b<a;b++){c=$C("OPTION");c.value=b;c.innerHTML=d[b].substr(0,4)+"年"+d[b].substr(4,2)+"月";if(b==0){c.selected="selected"}e.appendChild(c)}e.onchange=this._switchDropDown.Bind(this)},_show:function(c){var e=window["hk_company_incoming_statement_"+c];if(typeof e=="undefined"){return}var d=e.sheets.length;var b=[];for(var a=0;a<d;a++){b.push(e.sheets[a]["Year"])}this._sheets=e.sheets;this._showDropDown(b);this._showTable(e.sheets[0])},show:function(){var b=HKQuoteParams.getParam("code");if(b==null){return}var a=new IO.Script();a.load(__HK_COMPANY_INFO_URL+"?type=incoming_statement&code="+b,this._show.Bind(this,b))}};var CompanyInfoLinksTable={show:function(){var a=HKQuoteParams.getParam("code");$("company_info_table").innerHTML=$("company_info_table").innerHTML.replace(/__CODE__/g,a)}};function genRealtimeIndexs(){if(!hq_str_hkHSI||!hq_str_hkHSCCI||!hq_str_hkHSCEI){return}var d=SinajsQuoteParser.parse("hkHSI");var f=SinajsQuoteParser.parse("hkHSCCI");var b=SinajsQuoteParser.parse("hkHSCEI");var c=getColorCode(parseFloat(d[8]));var a=getColorCode(parseFloat(f[8]));var e=getColorCode(parseFloat(b[8]));$("realtimeIdxs").innerHTML='<span class="marginRight"><a href="http://finance.sina.com.cn/stock/hkstock/quote.html?code=HSI" target="_blank">恒生指数</a> <span style="color: '+c+'">'+parseInt(d[6])+" "+plusOrMinus(parseInt(d[7]))+" "+plusOrMinus(d[8])+'%</span> </span><span class="marginRight"><a href="http://finance.sina.com.cn/stock/hkstock/quote.html?code=HSCEI" target="_blank">国企指数</a> <span style="color: '+e+'">'+parseInt(b[6])+" "+plusOrMinus(parseInt(b[7]))+" "+plusOrMinus(b[8])+'%</span> </span><span><a href="http://finance.sina.com.cn/stock/hkstock/quote.html?code=HSCCI" target="_blank">红筹指数</a> <span style="color: '+a+'">'+parseInt(f[6])+" "+plusOrMinus(parseInt(f[7]))+" "+plusOrMinus(f[8])+"%</span></span>"}function plusOrMinus(a){return a>0?"+"+a:a}function showRealtimeIndexs(){var a=new IO.Script();a.load(G_REALTIME_INDEXS,genRealtimeIndexs)}var PageDisplayController={_rightRowControl:function(){if(HKQuoteParams.isIndex()){$("indexRightRow").style.display=""}else{$("stockRightRow").style.display=""}},_companyInfoLinksControl:function(){if(!HKQuoteParams.isIndex()){CompanyInfoLinksTable.show();$("company_info_section").style.display=""}},_commentControl:function(){var a=HKQuoteParams.getParam4();if(HKQuoteParams.isIndex()){a=HKQuoteParams.getParam("old_code")}$("comment_singlestock").src="http://finance.sina.com.cn/iframe/hkstock/quote_iframe.html?"+a},_invalidCodeControl:function(){var a=HKQuoteParams.getParam("code");if(typeof a=="undefined"){this.showNoStockMessage()}},showNoStockMessage:function(){$("center_row_container").style.visibility="hidden";$("center_row_message").innerHTML="<h1>对不起，您所查看的股票不存在或无法显示。</h1>";$("center_row_message").style.display=""},show:function(){this._invalidCodeControl();this._companyInfoLinksControl();this._rightRowControl();this._commentControl()}};var RanksCtrl=function(){this.Init.apply(this,arguments)};RanksCtrl.prototype={Init:function(d,a,e,b,c,f){if(d){this.xsrv=new IO.XSRV(d)}else{this.xsrv=new IO.XSRV("http://vip.stock.finance.sina.com.cn/quotes_service/api/jsonp.php")}this._container=b;this._service=a;this._paramObj=e;if(f){this.cid=f}},run:function(){this.xsrv.Call(this._service,this._render._Bind(this),this._paramObj,this.cid)},_render:function(a){var c=[this._headTpl];for(var g=0;g<a.length;g++){var h=this._rowTpl;for(var f in a[g]){switch(f){case"symbol":if(this._rowTpl.indexOf("SYMBOL")!=-1){h=h.replace(/SYMBOL/g,a[g].symbol)}break;case"publisher":if(this._rowTpl.indexOf("PUBLISHER")!=-1){h=h.replace(/PUBLISHER/g,a[g].publisher)}break;case"lasttrade":if(this._rowTpl.indexOf("LASTTRADE")!=-1){h=h.replace("LASTTRADE",Colorize(a[g].lasttrade,a[g].rate))}break;case"prevclose":if(this._rowTpl.indexOf("CHANGE")==-1){continue}if(a[g].chg){h=h.replace("CHANGE",Colorize(this._addSymbol((a[g].chg*1).toFixed(3)),a[g].rate));continue}var d=this._addSymbol((a[g].lasttrade*1-a[g].prevclose*1).toFixed(3));h=h.replace("CHANGE",Colorize(d,a[g].rate));break;case"rate":if(this._rowTpl.indexOf("ADRRATE")!=-1){var d=this._addSymbol((a[g].rate*1).toFixed(2))+"%";h=h.replace("ADRRATE",Colorize(d,a[g].rate));break}if(this._rowTpl.indexOf("CRATE")!=-1){var d=this._addSymbol((a[g].rate*100).toFixed(2))+"%";h=h.replace("CRATE",Colorize(d,a[g].rate))}break;case"volume":h=h.replace("VOLUME",(a[g].volume*1/1000000).toFixed(2)+"百万");break;case"amount":h=h.replace("AMOUNT",(a[g].amount*1/100000000).toFixed(2)+"亿");break;case"rank":switch(a[g].rank*1){case 0:h=h.replace("RANK","卖出");break;case 1:h=h.replace("RANK","持有");break;case 2:h=h.replace("RANK","买入");break;case 3:h=h.replace("RANK","--");break}break;case"listing_date":var b=a[g].listing_date.match(/(\d{4})(\d{2})(\d{2})/);h=h.replace("LISTING_DATE",(b.slice(1,4)).join("-"));break;case"last_trade_date":var b=a[g].last_trade_date.match(/(\d{4})(\d{2})(\d{2})/);h=h.replace("LAST_TRADE_DATE",(b.slice(1,4)).join("-"));break;case"department_name":var e=['<span title="',a[g][f],'">',subString(a[g][f],12),"</span>"].join("");h=h.replace("DEPARTMENT_NAME",e);break;default:if(h.indexOf(f.toUpperCase())!=-1){h=h.replace(f.toUpperCase(),a[g][f])}}}c.push(h)}c.push(this._footTpl);this._container.innerHTML=c.join("")},_colorize:function(b,a){if(a*1>0){return['<span class="up">',b,"</span>"].join("")}else{if(a*1<0){return['<span class="down">',b,"</span>"].join("")}}return b},_addSymbol:function(a){if(a*1>0){return["+",a].join("")}return a},_rowTpl:'<tr><th><a href="http://finance.sina.com.cn/stock/hkstock/quote.html?code=SYMBOL" target="_blank">NAME</a></th><td>LASTTRADE</td><td>CRATE</td></tr>',_headTpl:"<table><thead><tr><th>名称</th><th>最新价</th><th>涨跌幅</th></tr></thead><tbody>",_footTpl:"</tbody></table>"};var AnnCtrl={_html:'<table><tbody>@LIST@</tbody><tfoot>				<tr><td class="noLineAndVisited" colspan="2"><a target="_blank" href="http://hkstock.finance.sina.com.cn/company/list.php?symbol=@CODE@">更多>></a></td></tr>			</tfoot></table><div class="clear"></div>',_tr:'<tr><td>·<a title="@TITLE@" href="http://hkstock.finance.sina.com.cn/company/detail.php?aid=@ID@" target="_blank">@STITLE@</a></td><th>(@TIME@)</th></tr>',Init:function(){this._code=HKQuoteParams.getParam("code");var a=new IO.Script();a.load("http://hkstock.finance.sina.com.cn/company/affiche_list.php?code="+this._code,this._update.Bind(this))},_update:function(){this._data=window["affiche_"+this._code];if(this._data.length<1){$("ann_wrap").innerHTML='<div style="height:255px; line-height-255px; text-align:center;">该股票暂无公告数据</div>';return}var c=[];for(var b=0;b<this._data.length;b++){var a=this._data[b][2].length<33?this._data[b][2]:this._data[b][2].substring(0,31)+"..";c.push(this._tr.replace("@TITLE@",this._data[b][2]).replace("@STITLE@",a).replace("@TIME@",this._data[b][1]).replace("@ID@",this._data[b][0]))}$("ann_wrap").innerHTML=this._html.replace("@LIST@",c.join("")).replace("@CODE@",this._code)}};var StockNews=function(){this._get=function(a){return document.getElementById(a)};this._random=function(){return(new Date()).getTime()+Math.random().toString().replace("0.","")};this._bind=function(a,c){var b=this;return function(){var d=null;if(typeof c!="undefined"){for(var e=0;e<arguments.length;e++){c.push(arguments[e])}d=c}else{d=arguments}return a.apply(b,d)}};this._aevent=function(a,b,c){if(window.addEventListener){a.addEventListener(b,c,false)}else{if(window.attachEvent){a.attachEvent("on"+b,c)}}};this._count=function(){if(this._dateUTC!=null){this._dateUTC=new Date(this._dateUTC.getTime()+1000)}};this._load=function(a,c){var b=document.createElement("script");b.type="text/javascript";b._functionCallback=typeof c!="undefined"?c:new Function();b[document.all?"onreadystatechange":"onload"]=function(){if(document.all&&this.readyState!="loaded"&&this.readyState!="complete"){return}this._functionCallback(this);this._functionCallback=null;this[document.all?"onreadystatechange":"onload"]=null;this.parentNode.removeChild(this)};b.src=a;document.getElementsByTagName("head")[0].appendChild(b)};this._getQueryString=function(){var a=window.location.search;var e=a.match(/[?&]([^=]+)=([^&]+)(?=&|$)/g);var c={};if(e!=null){for(var b=0;b<e.length;b++){var d=e[b].replace(/^[?&]/,"").split("=");c[d[0]]=d[1]}}return c};this._fill=function(){if("hk_company_"+this._stringCode in window){var c=window["hk_company_"+this._stringCode];var b=[];b.push("<table><tbody>");for(var a in c){b.push('<tr><td>·<a href="'+c[a]["url"]+'" target="_blank">'+c[a]["NewsTitle"]+"</a></td><th>("+c[a]["Date"]+" "+c[a]["Time"]+")</th></tr>")}b.push('</tbody><tfoot><tr><td class="noLineAndVisited" colspan="2"><a target="_blank" href="http://biz.finance.sina.com.cn/hk/news.php?code='+this._stringCode+'">更多>></a></td></tr></tfoot></table>');this._elementTarget.innerHTML=b.join("")+'<div class="clear"></div>'}};this._initialize=function(){var a=this._getQueryString();if("code" in a){this._elementTarget=this._get("body_myRNews");this._stringCode=a.code;this._load("http://biz.finance.sina.com.cn/hk/news_js.php?code="+this._stringCode,this._bind(this._fill))}}};var AHctrl={_initload:null,Init:function(a){this._code=HKQuoteParams.getParam("code");if(!this._comparisonTbl[this._code]){return}if(!this._initload){this._code_a=this._comparisonTbl[this._code];this._price_hk=a;this._load()}else{this._price_hk=a}},_load:function(){var a=new IO.Script();a.load("http://hq.sinajs.cn/list="+this._code_a,this._update.Bind(this))},_update:function(){var d=window["hq_str_"+this._code_a].split(",");if(!this._initload){this._initload=1;var f=this._code_a.replace(/(sh|sz)/,"");var b=/(sh)/.test(this._code_a)?"上海":"深圳";this._html=this._html.replace("@CODE_F@",this._code_a).replace("@CODE_S@",f).replace("@NAME@",d[0]).replace("@MARKET@",b);$("ah_tbl").style.display="block"}var a=(d[3]-d[2]).toFixed(2);var e=d[3]*1!=0?(a/d[2]*100).toFixed(2):"0.00";var c=d[3]*1!=0&&this._price_hk*1!=0?(this._price_hk*0.87/d[3]*100).toFixed(2):"--";_html_tmp=this._html.replace("@PRICE@",this._colorize(d[3],a)).replace("@CG@",this._colorize(plusOrMinus(a),a)).replace("@RT@",this._colorize(plusOrMinus(e)+"%",a)).replace("@LAST@",d[2]).replace("@OPEN@",d[1]).replace("@V@",c);$("ah_tbl").innerHTML=_html_tmp;this._updateTimeout=window.setTimeout(this._load.Bind(this),10000)},_colorize:function(b,a){if(a>0){return this._spanHtml.replace("@COLOR@","#f00").replace("@TEXT@",b)}else{if(a<0){return this._spanHtml.replace("@COLOR@","#008000").replace("@TEXT@",b)}}return b},_spanHtml:'<span style="color:@COLOR@;">@TEXT@</span>',_html:'<div class="ah_name"><a href="http://finance.sina.com.cn/realstock/company/@CODE_F@/nc.shtml" target="_blank">@NAME@</a> (@MARKET@@CODE_S@)</div>			<div class="ah_content">				<table>				<tbody>					<tr>						<th rowspan="3"><h5>@PRICE@</h5><span>@CG@ (@RT@)</span></th>						<td>昨收盘:@LAST@</td>					</tr>					<tr><td>今开盘:@OPEN@</td></tr>					<tr><td>比价:@V@%</td></tr>				</tbody>				</table>			</div>',_comparisonTbl:{"03988":"sh601988","00914":"sh600585","01171":"sh600188","00902":"sh600011","00168":"sh600600","00323":"sh600808","00358":"sh600362","00386":"sh600028","01138":"sh600026","00347":"sz000898","01055":"sh600029","00995":"sh600012","00338":"sh600688","00177":"sh600377","00548":"sh600548","01065":"sh600874","00350":"sz000666","00670":"sh600115","00187":"sh600860","00921":"sz000921","01072":"sh600875","01033":"sh600871","00874":"sh600332","00719":"sz000756","00300":"sh600806","00763":"sz000063","00553":"sh600775","00317":"sh600685","00753":"sh601111","03968":"sh600036","00588":"sh601588","01071":"sh600027","01398":"sh601398","00991":"sh601991","00525":"sh601333","02628":"sh601628","02318":"sh601318","01919":"sh601919","02600":"sh601600","03328":"sh601328","00998":"sh601998","01108":"sh600876","00857":"sh601857","00939":"sh601939","02883":"sh601808","02338":"sz000338","01053":"sh601005","00042":"sz000585","00390":"sh601390","02866":"sh601866","01088":"sh601088","01186":"sh601186","01766":"sh601766","02899":"sh601899","01898":"sh601898","01812":"sz000488"}};function main(){PageDisplayController.show();GetTime.Init();showRealtimeIndexs();$("news_hkmarket").style.display="";VisitedStocksTable.show();ImgController.Init();window.nav=new Nav([["http://finance.sina.com.cn/stock/hkstock/","港股首页"],["http://finance.sina.com.cn/stock/","股票首页"],["http://finance.sina.com.cn/column/hkstocknews.html","港股新闻"],["http://finance.sina.com.cn/column/ggscyd.html","港股公司"],["http://finance.sina.com.cn/column/warrants.html","窝轮资讯"],["http://finance.sina.com.cn/column/ggIPO.html","IPO快讯"],["http://finance.sina.com.cn/column/hkstockcomment.html","大行评级"],["http://finance.sina.com.cn/column/hkstockresearch.html","港股研究"],["http://finance.sina.com.cn/money/globalindex/","环球市场"],["http://finance.sina.com.cn/column/othermarket.shtml","周边市场"],["http://hkstock.finance.sina.com.cn/","港股实时行情"]]);new TabSwitch($("imgTabs"),$("tagetImg"));new HkSearch($("hkSearchButton"),$("hkSearchInput"));CompanyInfoTable.show();IncomingStatementTable.show();if(!HKQuoteParams.isIndex()){$("news_grp_tabs").parentNode.style.display="block";var f=new TabSwitch($("news_grp_tabs"),$("news_grp_contents"));AnnCtrl.Init();var b=new StockNews();b._initialize()}window.setInterval("VisitedStocksTable.show()",60000);window.setInterval("HKQuote.update()",60000);if(HKQuoteParams.isIndex()){var a=new RanksCtrl(null,"HK_DelayQuotes.getTop",{tradetype:"security",num:10,sorttype:"rateup"},$("topten_gainer"),null,"topten_gainer");a.run();var d=new RanksCtrl(null,"HK_DelayQuotes.getTop",{tradetype:"security",num:10,sorttype:"ratedown"},$("topten_loser"),null,"topten_loser");d.run();var c=new RanksCtrl(null,"HK_DelayQuotes.getTop",{tradetype:"security",num:10,sorttype:"volume"},$("topten_volume"),null,"topten_volume");c._headTpl="<table><thead><tr><th>名称</th><th>成交量(股)</th><th>最新价</th></tr></thead><tbody>";c._rowTpl='<tr><th><a href="http://finance.sina.com.cn/stock/hkstock/quote.html?code=SYMBOL" target="_blank">NAME</a></th><td>VOLUME</td><td>LASTTRADE</td></tr>';c.run();var e=new RanksCtrl(null,"HK_DelayQuotes.getTop",{tradetype:"security",num:10,sorttype:"amount"},$("topten_turnover"),null,"topten_turnover");e._headTpl="<table><thead><tr><th>名称</th><th>成交额(元)</th><th>最新价</th></tr></thead><tbody>";e._rowTpl='<tr><th><a href="http://finance.sina.com.cn/stock/hkstock/quote.html?code=SYMBOL" target="_blank">NAME</a></th><td>AMOUNT</td><td>LASTTRADE</td></tr>';e.run()}};