// Window Resizer
var originalBgWidth = 1680;
var originalBgHeight = 700;
var minResizedHeight = 400;
var bgRatio = originalBgWidth/originalBgHeight;
var headerHeight = 100;
var footerHeight = 60;
var theWidth;
var theHeight;
var bgHeight;

function getDimensions() {
	// window dimensions
	if (window.innerWidth)
		theWidth=window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		theWidth=document.documentElement.clientWidth;
	else if (document.body)
		theWidth=document.body.clientWidth;

	if (window.innerHeight)
		theHeight=window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		theHeight=document.documentElement.clientHeight;
	else if (document.body)
		theHeight=document.body.clientHeight;

	bgHeight = theHeight - (headerHeight+footerHeight);
	// bgHeight has a maximum of 850 pixels
	if (bgHeight > originalBgHeight) {
		bgHeight = originalBgHeight;
	}
	if (bgHeight < minResizedHeight) {
		bgHeight = minResizedHeight;
	}
}

function resizeContent() {
	document.getElementById("flash-holder-container").style.height = bgHeight-50+"px";
	//calculate static image dimensions
	if (Math.round(theWidth/bgRatio) < bgHeight) {
		imgWidth = Math.round(bgHeight*bgRatio);
		imgHeight = bgHeight;
	} else if (Math.round(theWidth/bgRatio) > bgHeight) {
		imgWidth = theWidth;
		imgHeight = Math.round(theWidth/bgRatio);
	} else {
		imgWidth = theWidth;
		imgHeight = bgHeight;
	}

	// resize still image if used
	if (document.getElementById("content-img")) {
		document.getElementById("content-img").style.height = imgHeight+"px";
		document.getElementById("content-img").style.width = imgWidth+"px";
//        document.getElementById('w').style.height=document.getElementById("content-img").style.height;		
if (document.getElementById('st') != null)
        document.getElementById('st').style.height=eval(imgHeight-0)+"px";
		
if (document.getElementById('st_l') != null)
        document.getElementById('st_l').style.height=eval(imgHeight-0)+"px";

		// center image
		if (imgWidth > theWidth) {
			posLeft = Math.round((imgWidth-theWidth)/2);
			document.getElementById("content-img").style.left = "-"+posLeft+"px";
		} else {
			document.getElementById("content-img").style.left = "0px";
		}
		if (imgHeight > bgHeight) {
			posTop = Math.round((imgHeight-bgHeight)/2);
			document.getElementById("content-img").style.top = "-"+posTop+"px";
		} else {
			document.getElementById("content-img").style.top = "0px";
		}
	}

}

window.onresize = function() {
	getDimensions();
	resizeContent();
};

document.onkeyup = KeyCheck;       
function KeyCheck(e){
   var KeyID = (window.event) ? event.keyCode : e.keyCode;
   if (KeyID == 122) { getDimensions(); resizeContent();}
}

