var colors = new Array();

colors[0] = '#99116d';
colors[1] = '#b36694';
colors[2] = '#c187aa';
colors[3] = '#f39723';
colors[4] = '#e1a351';
colors[5] = '#e6b675';
colors[6] = '#eac088';


function InitHeight()
{
    var maxh  = 0;
    
    var elem  = document.getElementById('innerbody');
    var cols = elem.getElementsByTagName('div');
    
    for (i = 0; i < cols.length; i++)
    {
        var col = cols[i];
        
        if (col.scrollHeight)
        {
            if (col.scrollHeight > maxh)
                maxh = col.scrollHeight;
        }
        else if (col.offsetHeight)
        {
            if (col.offsetHeight > maxheight)
                maxh = col.offsetHeight;
        }
    }
    
    elem.style.height = maxh + 'px';
}

function InitGallery()
{
    var tbls = document.getElementsByTagName('table');
    
    for (i = 0; i < tbls.length; i++)
    {
        var tbl = tbls[i];
        
        if (tbl.className == 'albums')
        {
            var cells = tbl.getElementsByTagName('td');
            
            for (j = 0; j < cells.length; j++)
            {
                var cell = cells[j];
                
                if (cell.hasChildNodes() == false)
                    cell.appendChild(document.createElement('a'));
                
                cell.getElementsByTagName('a')[0].style.backgroundColor = RandomColor();
            }
        }
    }
}

function RandomColor()
{
    i = Math.round((colors.length - 1) * Math.random());
    
    return colors[i];
}


function InitPage()
{
    InitHeight();
    InitGallery();
}

window.onload = InitPage;
