var stockSpans = []; var stockSpansBuzz = []; var group_idx = 0; var id_groups=new Array(); function showStocksInfo() { var a = document.getElementsByTagName('SPAN') var current_feeder = '' var ig_counter =0; id_groups[ig_counter]=''; for(var i=0; i < a.length ;i++) { var name = '' + a[i].getAttribute('name') if (name.match(/^stockInfo\.\d+/)) { var r = name.split('\.'); stock_id=r[1]; id_groups[ig_counter] +='-'+stock_id; if (i % 5 ==4) { ig_counter++; id_groups[ig_counter]=''; } if (r.length>2) { display_type = r[2]; if (display_type == 'buzz') stockSpansBuzz[stockSpansBuzz.length]=a[i]; } else { stockSpans[stockSpans.length]=a[i]; } } } fetch_group(); } function fetch_group() { var myURL = "/Ext/Comp/I-Invest/StockInfo/CmmApiIinvest_getStockInfo/0,15264,toReplace,00.html" myURL = myURL.replace("toReplace", id_groups[group_idx]); createAjaxRequest(myURL); } function createAjaxRequest(url) { http_request = createHttpRequestObject(); if (!http_request) { alert('Error creating XMLHTTP object'); return false; } http_request.onreadystatechange = getResponse; http_request.open('GET', url, true); http_request.send(null); } function createHttpRequestObject(){ var request; if (window.XMLHttpRequest) { // IE7, Mozilla, Safari, etc. request = new XMLHttpRequest(); if (request.overrideMimeType) { request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE 6 and previous try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } return request; } function getResponse() { if (http_request.readyState == 4) { if (http_request.status == 200) { //get the XML response and loop elements var res = http_request.responseText.split('\n'); fillSpans(res); fillStockBox(res); http_request = null; group_idx++; if (group_idx < id_groups.length) fetch_group(); } else { return false; } } } var toDisplay; function fillSpans(aRes) { for (i=1;i"+aStock[4]+"" stockList += stock_id + " "; } } if (retHtml != "" && document.getElementById('articleStockBox') != null) { document.getElementById('articleStockBox').innerHTML += retHtml; document.getElementById('StockTagBox').style.display = 'block'; document.getElementById('stocksTagIdList').innerHTML = stockList; } } function getStockHTML(aStock) { stock_id=aStock[0]; stock_value=aStock[1]; stock_percent=aStock[2]; var float_percentageChange = parseFloat(stock_percent) color = 'black' arrow = '/images/pixel.gif' if (float_percentageChange > 0) {color = '#229100'; arrow = '/images/arrow-green-up.gif'} if (float_percentageChange < 0) {color = '#d01e25'; arrow = '/images/arrow-red-down.gif'} if (toDisplay) { var article_id = ''; var tempCheck = top.location.href.replace('#dontadd', '').split(',L-'); if (tempCheck.length > 1) { tempCheck = tempCheck[1].split(',00.html')[0]; article_id = tempCheck; if (tempCheck.indexOf('-') > -1) {article_id = tempCheck.split('-')[0];} } var stockAddLink = ''; } else { var stockAddLink = ""; } return '' + '' + '' + '' + '' + (this.color != 'black' ? '' + '' : '' ) + '' + '' + '
(' + stock_value + '' + formated_number(stock_percent,'',2,'%') + ''+stockAddLink+')
' } function getStockHTMLBuzz(aStock) { stock_id=aStock[0]; stock_value=aStock[1]; stock_percent=aStock[2]; stock_delta = aStock[3]; var float_percentageChange = parseFloat(stock_percent) color = 'black' arrow = '/images/pixel.gif' if (float_percentageChange > 0) {color = '#229100'; arrow = '/images/buzz-green-arrow.gif'} if (float_percentageChange < 0) {color = '#d01e25'; arrow = '/images/buzz-red-arrow.gif'} return '' + '' + '' + (this.color != 'black' ? '' :'' ) + '' + '' + '
' + stock_value + '
' + formated_number(stock_percent,'',2,'%') + '
' + stock_delta + '
0.00
0.0
' } function formated_number(n,s,decimalpoints,a) { function with_comma(n,r) {return (n >= r) ? with_comma(Math.floor(n / r),r) + "," + (r + (n % r)).toString().replace(/^1/,'') : n} try { var n = parseFloat(n.replace(/,/g,"")) if (isNaN(n) || n == 0) {return "---"} var sign = n < 0 ? '-' : s var p = 1 for(var i=0; i < decimalpoints ;i++) {p *= 10} var sn = Math.abs(new String(Math.round(n * p))).toString() while(sn.length < decimalpoints + 1) {sn = "0" + sn} return sign + with_comma(parseInt(sn.substring(0,sn.length - 2)),1000) + "." + sn.substring(sn.length - 2) + a } catch(ex) {fail("formated_number",ex)} } try {showStocksInfo()} catch(ex) {alert(ex.description);}