﻿// JScript File
function elem(id) {
    if (document.getElementById != null) {
        return document.getElementById(id);
    }
    if (document.all != null) {
        return document.all[id];
    }
    if (document.layers != null) {
        return document.layers[id];
    }
    return null;
}

function height(id) {
    var e = elem(id);
    if (e) {
        return parseInt(e.offsetHeight);
    }
    return 0;
}

function windowHeight() {
    var height = 0;
    if (typeof (window.innerHeight) == 'number') {
        //Non-IE
        height = window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        //IE 6+ in 'standards compliant mode'
        height = document.documentElement.clientHeight;
    } else if (document.body && document.body.clientHeight) {
        //IE 4 compatible
        height = document.body.clientHeight;
    }
    return parseInt(height);
}

function windowWidth() {
    var width = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        width = window.innerWidth;
    } else if (document.documentElement && document.documentElement.clientWidth) {
        //IE 6+ in 'standards compliant mode'
        width = document.documentElement.clientWidth;
    } else if (document.body && document.body.clientWidth) {
        //IE 4 compatible
        width = document.body.clientWidth;
    }
    return parseInt(width);
}

function stretchPage() {

    var headHeight = height('header');
    var footHeight = height('footer');
    var titleHeight = height('title');
    var copyHeight = height('copyrightfooter');
    var spacer1Height = height('spacer1');
    var winHeight = windowHeight();
    var newheight = winHeight - headHeight - footHeight - titleHeight - copyHeight - spacer1Height - 20;
    //var newwidth = windowWidth() - 280;
    if (newheight < 1) newheight = 1; // set to 1 because there are bugs in moz and konq when setting height to 0
    if (typeof(leftCol) != "undefined")
        leftCol.style.height = newheight + 'px';
    if (typeof(rightCol) != "undefined")
        rightCol.style.height = newheight + 'px';
    if (typeof(SingleCol) != "undefined")
        SingleCol.style.height = newheight + 'px';
}

window.onload = stretchPage;
window.onresize = stretchPage;