	// After/during the page rendering, set the initial height.
  	window.onload = function()
	{
		setHeight();
	}

	// If the window is resized for any reason, reset the height
	// to auto and then compute the new height to set 'main' to.
	window.onresize = function()
	{
		resetHeight();
		setHeight();
	}
	
	// Before computing the new height to set main to,
	// this resets it to auto to avoid any complications.
	function resetHeight()
	{
		var Main = document.getElementById("main");
		Main.style.height = "auto";
	}

	function setHeight()
	{
		// Verify that we can both get document elements, and that the getWindowHeight() returned a usable value.
		if (document.getElementById){
			var wHeight = getWindowHeight();

			if (wHeight > 0){
				var Main = document.getElementById("main");
				var Header = document.getElementById("header");
				var Footer = document.getElementById("footer");

				// If all of the page elements (header, main, footer) combined are shorter
				// than the height of the window, make main taller to compensate.
				if (wHeight - (Main.offsetHeight + Header.offsetHeight + Footer.offsetHeight) >= 0){
					// 200 is a magic number used to account for the breathing room on the top and bottom of the page.
					// this might have to be changed later on to account for banner ads, etc.
						Main.style.height = (wHeight - Header.offsetHeight + Footer.offsetHeight - 125) + "px";
				}
			}
		}
	}

	// window.innerHeight, documentElement.clientHeight, and body.clientHeight
	// are the 3 preffered methods to determine the user's browser height.
	// some browsers might not have some of these, so account for them all.
	function getWindowHeight()
	{
		var wHeight = 0;

		if (typeof(window.innerHeight) == "number"){
			wHeight = window.innerHeight;
		} else {
			if (document.documentElement &&
				document.documentElement.clientHeight){
				wHeight = document.documentElement.clientHeight;
			} else {
				if (document.body && document.body.clientHeight){
					wHeight = document.body.clientHeight;
				}
			}
		}

		return wHeight;
	}


