/*
InitiateScript.js

Purpose:        Execute commands when the onload event is called in the body tag.

Subroutines:    
body_onload()
called when every page is loaded on the onload event.
                
setTopNavStyles()
function to set the id's of the items in the navigation bar at the top
of the page

TODO:           add a check so it does not altar the styles in browsers that support CSS3

*/

window.onload = body_onload;

var OnResize = 'setBottomEmptySpace()';
window.onresize = function() { eval(setBottomEmptySpace()); };

function body_onload() {
    setTopNavStyles();
    setBottomEmptySpace();
    if (typeof window.tagCloud == 'function') {
        // function exists, so we can now call it
        tagCloud();
    }
    
    
}

function setBottomEmptySpace() {
    var windowHeight;
    if (window.innerHeight) {
        windowHeight = window.innerHeight;
    }

    if (!windowHeight) {
        windowHeight = document.documentElement.clientHeight;
    }
    if (!windowHeight) {
        windowHeight = document.body.clientHeight;
    }
    var bottomEmptySpace
    if ((windowHeight) && document.getElementById("divBottomEmpty")) {
        bottomEmptySpace = windowHeight - document.getElementById("divBottomEmpty").offsetTop;

    }
    if (bottomEmptySpace > 0) {
        document.getElementById("divBottomEmpty").style.height = (bottomEmptySpace - 2) + 'px';
    }
    else {
        if (/MSIE/.test(navigator.userAgent)) {
            if (document.body.childNodes[2]) {
                //document.body.removeChild(document.body.childNodes[2]);
                var offHeight = document.getElementById('divBackground').offsetHeight;
                var newHeight = windowHeight - offHeight;
                if (newHeight <= 0) {
                    newHeight = 17;
                } 
                document.getElementById("divBottomEmpty").style.height = newHeight + "px";
                document.getElementById("divBottomEmpty").style.zIndex = "-1";
                
                
            }
        }
        else {
            document.getElementById("divBottomEmpty").style.height = 0 + 'px';
        }
    }
}

