// Marc
function detectBrowserSize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    //check size and set style
    setBottomBarStyleRelSize(myWidth, myHeight)

    //Debug information to see screen sizes
    //  	document.getElementById('debug').innerHTML = 'Browser Width = ' + myWidth ;
    //  	document.getElementById('debug').innerHTML += '<br/>Browser Height = ' + myHeight;
}

function setBottomBarStyleRelSize(w, h) {
    var spaceC1newH;
    var spaceC1 = document.getElementById('homeColumnSpacer');
    var contentBody = document.getElementById('content');
    var column1 = document.getElementById('homeColumn1');
    var column2 = document.getElementById('homeColumn2');
    var columnSep = document.getElementById('homeColumnSep2Tile');

    if (column1.offsetHeight > column2.offsetHeight) { spaceC1newH = column1.offsetHeight; } else { spaceC1newH = column2.offsetHeight; }
    spaceC1.style.height = spaceC1newH + 38 + "px";

    if (document.getElementById('homeContentBottom')) {
        var homeCB = document.getElementById('homeContentBottom');
        contentBody.style.height = spaceC1newH + 55 + homeCB.offsetHeight + "px";
    }
    else {
        contentBody.style.height = spaceC1newH + 55 + "px";
    }
    columnSep.style.height = spaceC1newH - 10 + "px";


    var cntH = 538; //default content height
    var topBanner = document.getElementById('topBanner');
    var allContentH = contentBody.offsetHeight + topBanner.offsetHeight + 117 + 59; //content-height + banner + bottomBar thingy + rightsBar


    if (h > allContentH)
    {
        if (contentBody.offsetHeight < cntH) {
            $(document.getElementById('bottomBarContainer')).fadeIn('100');
            document.getElementById('bottomBarContainer').className = 'bottomLogosTile';
        }
        else {
            document.getElementById('bottomBarContainer').className = 'bottomLogosTileStatic';
            if (contentBody.offsetHeight > cntH) {
                document.getElementById('bottomBarContainer').className = 'bottomLogosTile';
            }
        }
    }
    else {
        $(document.getElementById('bottomBarContainer')).fadeIn('100');
        document.getElementById('bottomBarContainer').className = 'bottomLogosTileStatic';

    }
}

window.onload = function() {
    detectBrowserSize();

    //For bottom bar image animation
    //$(document.getElementById('bottomBarContainer').getElementsByTagName('img')).hide();
    //$(document.getElementById('bottomBarContainer').getElementsByTagName('img')).slideDown('100');

    setStyleForMac('rbOne', 1);
    setStyleForMac('rbTwo', 2);
}

window.onresize = function() {
    detectBrowserSize();
}

window.onscroll = function() {
    detectBrowserSize();
}

//window.onclick = function() {
//    detectBrowserSize();
//}

//window.onmouseup = function() {
//    detectBrowserSize();
//}

document.getElementsByTagName('div').onmouseout = function() {
    detectBrowserSize();
}

document.getElementsByTagName('li').onmouseout = function() {
    detectBrowserSize();
}
