// uses jquery so we don't clobber onload
$('document').ready(function(){
  setDiv();
});
function setDiv() {
	// get a few elements to check
	var nb = document.getElementById("navbar");
	var ht = document.getElementById("headertop");
	var hd = document.getElementById("headerdown");
	var co = document.getElementById("content");
	var ft = document.getElementById("footer");
    // find the correct vertical extent 
	var wh = getWindowHeight();
    // get height of stuff (header is in content padding)
    var sh = co.offsetHeight + ft.offsetHeight;  
    //
    var newh=wh > sh ? wh : sh;
	// get the window height and width
	nb.style.height = newh + "px";
	// subtract the headertop and continue header down
	var hth = ht.offsetHeight;
	var hdh = hd.offsetHeight;
	hd.style.height = newh - hth + "px";
	// now put the fotter under the content
	ft.style.top=co.offsetHeight + "px";
	ft.style.left=co.offsetLeft + "px";
}
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof (window.innerHeight) == "number") {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof (window.innerWidth) == "number") {
		windowWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}
