﻿function getWindowHeight()
{
    var windowHeight = 0;
    if (typeof (window.innerHeight) == 'number')
    {
        windowHeight = window.innerHeight;
    }
    else
    {
        if (document.documentElement && document.documentElement.clientHeight)
        {
            windowHeight = document.documentElement.clientHeight;
        }
        else
        {
            if (document.body && document.body.clientHeight)
            {
                windowHeight = document.body.clientHeight;
            }
        }
    }
    return windowHeight;
}

function getWindowWidth()
{
    var windowWidth = 0;
    if (typeof (window.innerWidth) == 'number')
    {
        windowWidth = window.innerWidth;
    }
    else
    {
        if (document.documentElement && document.documentElement.clientWidth)
        {
            windowWidth = document.documentElement.clientWidth;
        }
        else
        {
            if (document.body && document.body.clientWidth)
            {
                windowWidth = document.body.clientWidth;
            }
        }
    }
    return windowWidth;
}


function setFooter()
{

    if (document.getElementById)
    {
        var windowHeight = getWindowHeight();
        if (windowHeight > 0)
        {
            var headerHeight = document.getElementById('header').offsetHeight + document.getElementById('topbar').offsetHeight + document.getElementById('crumbbar').offsetHeight ;
            var contentHeight = document.getElementById('contents').offsetHeight + 7; 
            var footerElement = document.getElementById('footer');
            var footerHeight = footerElement.offsetHeight;
            if (windowHeight - (headerHeight + contentHeight + footerHeight) >= 0)
            {
                footerElement.style.top = (windowHeight - (headerHeight + contentHeight + footerHeight)) + 'px';
            }
            else
            {
                footerElement.style.top = '0px';
            }
        }

    }
}

//    
//        //setAldoc();
//    }

//function setAldoc() 
//{
//    if (document.getElementById) {
//        var windowHeight = getWindowHeight();
//        var windowWidth = getWindowWidth();
//        if (document.getElementById('pagea')) {
//            if (windowHeight > 0) {
//                var headerHeight = document.getElementById('header').offsetHeight;
//                var contentHeight = document.getElementById('contents').offsetHeight;
//                var footerElement = document.getElementById('footer');
//                var footerHeight = 0; /*footerElement.offsetHeight;*/
//                if (windowHeight - (headerHeight + contentHeight + footerHeight) >= 0) {
//                    var myHeight = (windowHeight - (headerHeight + footerHeight + 40)) + 'px';
//                    //var myWidth = (windowWidth - (300)) + 'px';
//                    document.getElementById('contents').style.height = myHeight;
//                    document.getElementById('pagea').style.height = myHeight;

//                    //document.getElementById('contents').style.width = myWidth;
//                    //document.getElementById('pagea').style.width = myWidth;

//                }
//            }
//        }
//    }
//}
window.onload = function() { setFooter(); }
window.onresize = function() { setFooter(); }

