var bLoaded = false;
var clientAreaX = 0;
var clientAreaY = 0;


function mouseTrap() {
	hideAll();
	hideEl(getEl("mousetrap"));
}

function handleResize() {		
	clientAreaX = getViewportWidth();
	clientAreaY = getViewportHeight();
	document.getElementById("mousetrapImg").width = clientAreaX;
	document.getElementById("mousetrapImg").height = clientAreaY - 10;
	repositionFooter();	
	bLoaded = true;

}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getViewportWidth() {
	var width = 0;
	if( document.documentElement && document.documentElement.clientWidth )
		width = document.documentElement.clientWidth;
	else if( document.body && document.body.clientWidth )
		width = document.body.clientWidth;
	else if( window.innerWidth )
		width = window.innerWidth - 18;
	return width;
}

function getViewportHeight() {
	var height = 0;	
	
	if( document.documentElement && document.documentElement.clientHeight )
		height = document.documentElement.clientHeight;
	else if( document.body && document.body.clientHeight )
		height = document.body.clientHeight;
	else if( window.innerHeight )
		height = window.innerHeight - 18;
		
	return height;
	
}

function repositionFooter() {
	var mainContent = document.getElementById("mainContent");
	var footer = document.getElementById("footer");
	var clientY = getViewportHeight();
	
	mainContent.style.height = 0;
	//Equation: (client area height) - (footer height) - (header height) - (number of pixels for borders/dividers/etc.)
	var newHeight = Math.max((clientY - footer.offsetHeight),findPosY(footer));
	mainContent.style.height = newHeight + "px";

	/*
    var footer = getEl("footer");
    var footerKey = getEl("footerKey");
    var currY = findPosY(footerKey) + 25;
    var height = getViewportHeight();
    if(height > currY) {
        footer.style.position = "absolute";
        footer.style.top = ((height) - (footer.offsetHeight)) + "px";
    }
	*/
}
	
