var maxW = 1574;
var maxH = 850;
var minW = 800;
var minH = 850;
var tweakW = 20;
var tweakH = 0;
var el1 = $('flash_object_embed');//.width = 700;
var el2 = $('flash_object_embed2');//.width = 700;
var resizeH = false;
var resizeW = true;

function $(item) {return document.getElementById ? document.getElementById(item) : document.all[item];}
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function winH() {
    var htmlheight = document.body.parentNode.scrollHeight;
    var windowheight = window.innerHeight;
    
    if(typeof(htmlheight) == 'undefined')
        return windowheight;
    else
        if(typeof(windowheight) == 'undefined')
            return htmlheight - tweakH;
        else
            return (htmlheight < windowheight) ? htmlheight : windowheight;
}

function winW() {
    var htmlwidth = document.body.parentNode.scrollWidth;
    var windowwidth = window.innerWidth;
    
    if(typeof(htmlwidth) == 'undefined')
        return windowwidth;
    else
        if(typeof(windowwidth) == 'undefined')
            return htmlwidth - tweakW;
        else
            return (htmlwidth < windowwidth) ? htmlwidth : windowwidth;
}

function resizeFlash(){  
    if(resizeW) {
        var smallerW = winW();
        if(smallerW < maxW && smallerW > minW) {
            if(el1) el1.style.width = smallerW + "px";
            if(el2) el2.style.width = smallerW + "px";
        }
    }
    
    if(resizeH) {
        var smallerH = winH();
        if(smallerH < maxH && smallerH > minH) {
            if(el1) el1.style.height = smallerH + "px";
            if(el2) el2.style.height = smallerH + "px";
        }
    }
} 

function setResize() {
    window.onresize = function() {
        resizeFlash();
    }
}

addLoadEvent(resizeFlash);
addLoadEvent(setResize);
