﻿function getBrowserSize() {
    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;
    }            
    return {width:myWidth, height:myHeight};
}
function izOnLoad(){    
    var bgPath = "/files/graphics/agents/backgrounds/background" + Math.ceil(Math.random()*5) + ".jpg";
    document.getElementById("background").src = bgPath;
    izOnResize();
}
function izOnResize(){
    var browser = getBrowserSize()
    if(browser.width<817){
        browser.width=817;
    }
    var contentHeight = document.getElementById("contentInner").clientHeight;
    if(contentHeight>browser.height-107){
        browser.height = contentHeight+160;
    }

    if (browser.width > 800) {

        document.getElementById("content").style.height = (browser.height - 107) + "px";
        document.getElementById("footer").style.top = (browser.height) + "px"; //browser.height-30 + "px";        
        document.getElementById("footer").style.width = (browser.width) + "px";

        var htmlheight = document.body.parentNode.clientHeight;
        var windowheight = window.screen.height;

        document.getElementById("backgroundContainer").style.width = (browser.width) + "px"; //(browser.width-20) + "px";
        document.getElementById("backgroundContainer").style.height = (browser.height + 20) + "px";
        document.getElementById("backgroundOverlay").style.height = (browser.height + 20) + "px";
    }
    else {
        document.getElementById("content").style.height = (browser.height - 107) + "px";
        document.getElementById("footer").style.top = (browser.height) + "px"; //browser.height-30 + "px";        
        document.getElementById("footer").style.width = (browser.width) + "px";

        var htmlheight = document.body.parentNode.clientHeight;
        var windowheight = window.screen.height;

        document.getElementById("backgroundContainer").style.width = (browser.width) + "px"; //(browser.width-20) + "px";
        document.getElementById("backgroundContainer").style.height = (browser.height + 20) + "px";
        document.getElementById("backgroundOverlay").style.height = (browser.height + 20) + "px";
    }
}
function showImgOverlay(divId) {
    document.getElementById(divId).style.display = "block";
}
function hideImgOverlay(divId) {
    document.getElementById(divId).style.display = "none";
}
function LoadImage(img, url) {
    img.onload = null;
    img.src = url;
}
function ChangeFilename(uploadId, labelId) {
    var filename = document.getElementById(uploadId).value.replace(/^.*\\/, '');
    var label = document.getElementById(labelId);
    label.innerText = filename;
}

window.onload = izOnLoad;
window.onresize = izOnResize;


