﻿function SimpleTab()
{
    this._tabs = arguments;
    if (arguments.length > 0)
    {
        this._selectedIndex = 0;
    }
};

SimpleTab.prototype.set_selectedIndex = function (index)
{
    for (var i = 0; i < this._tabs.length; i++)
    {
        document.getElementById(this._tabs[i]).className = 'tab';
    }
    document.getElementById(this._tabs[index]).className = 'tabactive';
    this._selectedIndex = index;
};

SimpleTab.prototype.get_selectedIndex = function ()
{
    return this._selectedIndex;
};

function Common()
{    
}

Common.prototype.highlightSymbol = function()
{
    var links = document.getElementsByTagName('a');
    for(var i = 0; i < links.length; i++)  
    {  
        if (links[i].className == 'symbol') 
        {            
            var symbol = links[i].innerText;
            links[i].href = "/Overview.aspx?Symbol=" + symbol;
        }   
    }    
};

function hideTip()
{
    if (typeof(ttip) != 'undefined') ttip.PrepareToHide()
}

function showTip(evt)
{
    var symbol;
    if (typeof window.event!="undefined") 
        symbol=event.srcElement.innerText;
    else
        symbol=evt.target.innerText; 
        
    if (typeof(ttip) != 'undefined') ttip.Show(evt,'/Charts/SymbolInfo.aspx?Symbol=' + symbol, 260, 335);
}
  
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}

function formatDecimal(i)
{            
	var n = new String(i);
    var a = [];
    while(n.length > 3)
    {
	    var nn = n.substr(n.length-3);
	    a.unshift(nn);
	    n = n.substr(0,n.length-3);
    }
    if(n.length > 0) { a.unshift(n); }
    n = a.join(",");
    return n;
}

function formatMinusPlus(number)
{
    if (number < 0) return number;
    else if (number > 0) return "+" + number;
    
    return number;
}  

var common = new Common();