/***********************************
*           stjames.js             *
*                                  *
*  This javascript is for the      *
*  index.html and related pages    *
*                                  *
*  Coded by: gene@genedodge.com    *
***********************************/


// when browser window resizes, re-setup page
window.onresize = bgSetup;


function bgSetup() {
	/*-------------------------------\
	| This function sets the css to  |
	| make the body of the page fill |
	| the entire browser window even |
	| if the content does not.       |
	| basically, makes it purdy      |
	\-------------------------------*/

	// containerHeight needs to be 155px larger than contentHeight
	// contentHeight needs to be at least 40px larger than leftContentHeight and
	//  no more than 155px smaller than containerHeight
	containerElem = document.getElementById("container");
	contentElem = document.getElementById("content");
	leftContentElem = document.getElementById("left_content");

	leftContentElem.style.height = "";

	//if browser supports window.innerWidth
	if (window.innerHeight) {
		broWinHeight = window.innerHeight;
	}
	//else if browser supports document.all (IE 4+)
	else if (document.all) {
		broWinHeight = document.documentElement.clientHeight;
	}

	//set broWinHeight to an integer for calculations
	broWinHeight = parseInt(broWinHeight);

	//get the height of each element
	containerHeight = containerElem.offsetHeight;
	contentHeight = contentElem.offsetHeight;
	leftContentHeight = leftContentElem.offsetHeight;

	if ((leftContentHeight + 40) > (broWinHeight - 155)) {
		containerElem.style.height = (leftContentHeight + 40 + 155) + "px";
		contentElem.style.height = (leftContentHeight + 40) + "px";
	} else  {
		containerElem.style.height = broWinHeight + "px";
		contentElem.style.height = (broWinHeight - 155) + "px";
		leftContentElem.style.height = (broWinHeight - 225) + "px";
	}

// alert statement for debugging
//alert("setupPage function was run\nBroWinHeight: " + broWinHeight + "\ncontainerHeight (blue): " + containerElem.style.height + "\ncontentHeight (green): " + contentElem.style.height + "\nleftContentHeight (red): " + leftContentElem.style.height);

}