/*================= Global variables ==================*/
var MAINHEIGHT;	/*Container height*/
var HEADERHEIGHT;	/*Header height*/
var CONTHEIGHT;	/*Container height*/
var FOOTERHEIGT;	/*Footer height*/
/*=====================================================*/

/*setvariables function*/
function setVariables () {
	HEADERHEIGHT = document.getElementById("header").offsetHeight;
	CONTHEIGHT 	 = document.getElementById("container").offsetHeight;
	FOOTERHEIGT  = document.getElementById("footer").offsetHeight;
	MAINHEIGHT 	 = HEADERHEIGHT + CONTHEIGHT + FOOTERHEIGT - 81;
}

function fixLayout () {
	if (document.documentElement.clientHeight > MAINHEIGHT ) {
		document.getElementById("container").style.height = document.documentElement.clientHeight - HEADERHEIGHT + 81 - FOOTERHEIGT +"px";
	} else {
		document.getElementById("container").style.height = CONTHEIGHT + "px";
	}
}
/*Listeners*/
if (window.addEventListener){
	window.addEventListener("load", setVariables, false);
	window.addEventListener("load", fixLayout, false);
	window.addEventListener("resize", fixLayout, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", fixLayout);
	window.attachEvent("onload", setVariables);
	window.attachEvent("onresize", fixLayout);
}