window.onload = function() {
    setMainImageSize();
    footerInit();
}

window.onresize = function() {
    setMainImageSize();
}

IE7_PNG_SUFFIX = "-trans.png";
var type = "";
if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";
if (document.all) type="IE";
if (document.layers) type="NN";
if (!document.all && document.getElementById) type="MO";

var MAX_height = 12000;

function setMainImageSize() {
	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;
    }
    
    var new_image_width = myWidth;
    var new_image_height = new_image_width*(2000/3000);
    
    if(new_image_height < myHeight) {
        
        new_image_height = myHeight;
        new_image_width = new_image_height*(3000/2000);
        
    }
    
    var mainimage = document.getElementById('mainimage');
    
    mainimage.setAttribute("className", "dynamic");
    
    mainimage.style.height = new_image_height + "px";
    mainimage.style.width = new_image_width + "px";
    
    if(new_image_width < 800) {
        mainimage.src = "/images/backgrounds/" + mainimage.getAttribute("alt") + "800.jpg";
    } else if(new_image_width < 1000) {
        mainimage.src = "/images/backgrounds/" + mainimage.getAttribute("alt") + "1000.jpg";
    } else if(new_image_width < 1500) {
        mainimage.src = "/images/backgrounds/" + mainimage.getAttribute("alt") + "1500.jpg";
    } else if(new_image_width < 2000) {
        mainimage.src = "/images/backgrounds/" + mainimage.getAttribute("alt") + "2000.jpg";
    } else {
        mainimage.src = "/images/backgrounds/" + mainimage.getAttribute("alt") + ".jpg";
    }
    
    var topsize = (myHeight / 2) - 40;
    
    if(type == "IE") {
        var topsize = (myHeight / 2) - 80;
    }
    
    if(topsize > 250) {
        
        if(document.getElementById('topcontainer').offsetHeight < topsize) {
            document.getElementById('topcontent').style.height = topsize + "px";
        } else {
            document.getElementById('topcontent').style.height = (document.getElementById('topcontainer').offsetHeight + 30 ) + "px";
        }
    }
}
