// Special method for styling of the share data tables from Cision
function styleTable(table)
{
    var tableRows = table.getElementsByTagName("tr");
    
    for (i = 0; i < tableRows.length; i++)
    {
        if (i > 0)
        {
            if (i % 2 > 0)
                tableRows[i].style.backgroundColor = "#EEEBE6";
        }
    }
}

// Looks for tables to style
function findTablesToStyle()
{
    var tables = document.getElementsByTagName("table");
    
    for (tableIndex = 0; tableIndex < tables.length; tableIndex++)
    {
        if (tables[tableIndex].className == "infoTable")
            styleInfoTable(tables[tableIndex]);
        
        if (tables[tableIndex].className == "financialTable")
            styleFinancialTable(tables[tableIndex]);
    }
}

// Loops the rows of an infotable and set CSS-classes.
function styleInfoTable(table)
{
    var tableRows = table.getElementsByTagName("tr");
    var firstRow = 1;
    var rowIndex = 0;
    
    if (tableRows.length == 0)
        return;
    
    if (tableRows[0].getElementsByTagName("th").length == 0)
        firstRow = 0;
    
    for (i = firstRow; i < tableRows.length; i++)
    {
        if (rowIndex % 2 == 0)
        {
            tableRows[i].className = tableRows[i].className + " evenRow";
        }
        
        rowIndex ++;
    }        
}

// Loops the rows and cells of a financial table and set CSS-classes.
function styleFinancialTable(table)
{
    
    var tableRows = table.getElementsByTagName("tr");
    
    for (i = 0; i < tableRows.length; i++)
    {
        var tableCells = tableRows[i].getElementsByTagName("td");
        
        if (tableCells.length == 0)
            tableCells = tableRows[i].getElementsByTagName("th");
        
        for (j = 0; j < tableCells.length; j++)
        {
            if (j == 0)
            {
            }
            else
            {
                if (j % 2 > 0)
                {
                    tableCells[j].className = tableCells[j].className + " highlight";    
                }
                else
                {
                    tableCells[j].className = tableCells[j].className + " normal";
                }
            }
        }       
    }
}
