/*
 * Body Resize v1.0
 *
 * Built by Jo Albright with Hybr-id.
 *
 * This code finds the window height and resizes the body to fit it, if the body height is less than the window height.
*/

var htmlHeight = 0;
var windowHeight = 0;
var windowWidth = 0;
var scrollBar = 0;

window.onload = function() {changeHeight(true);}
window.onresize = function() {changeHeight(false);}

function changeHeight(firsttime) {
    if (typeof(window.innerHeight) == 'number') {
        //Non-IE
        windowHeight = window.innerHeight;
        windowWidth = window.innerWidth;
        scrollBar = 15;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        //IE 6+ in 'standards compliant mode'
        windowHeight = document.documentElement.clientHeight;
        windowWidth = document.documentElement.clientWidth;
    } else if (document.body && document.body.clientHeight) {
        //IE 4 compatible
        windowHeight = document.body.clientHeight;
        windowHeight = document.body.clientWidth;
    }

    if (firsttime == true) {
        htmlHeight = document.body.offsetHeight
    }

    scrollWidth = document.body.scrollWidth;
    scrollPosition = document.body.scrollLeft;
    //console.log(scrollWidth+" : "+scrollPosition+" : "+windowWidth)
    //console.log(htmlHeight, scrollWidth, scrollPosition, windowHeight)
    if (htmlHeight < windowHeight)
    {
        if (windowWidth < scrollWidth) {
            document.body.style.mimHeight = (windowHeight - scrollBar) + "px";
        } else {
            document.body.style.minHeight = windowHeight + "px";
        }
    }
}
