// JavaScript Document
<!--
var usePaddingTrick = true;

function rebuild() {
	/* Rebuild the Page Width from the Page Height... */
	
	var page = document.getElementById("page");
	var content = document.getElementById("content");
	
	var minPageWidth = 775;
	var pageHeight = page.offsetHeight;
	var pageWidth = pageHeight;
	pageWidth = max(pageWidth, minPageWidth);
	
	var headerHeight = 130; //document.getElementById("header").offsetHeight;
	var footerHeight = 100; //document.getElementById("footer").offsetHeight;
	page.style.width = max(pageWidth, minPageWidth) + "px";
	
	
	/* Realign the pageInset with the bottom... remember, the min is 0! */
	var menuHeight = document.getElementById("menu").offsetHeight;
	var pageInset = document.getElementById("pageInset");
	
	pageInset.style.bottom = min(0, pageHeight - menuHeight - headerHeight - pageInset.offsetHeight)+"px";
	
	
	/* Resize the page background to fit. */
	var bg = document.getElementById("background");
	bg.style.width = pageWidth+"px";
	
	
	/* And the weird thing with the content background... ? */
	// That is, if resolution high enough, show ALL of bgImage, and
	// add white to the top.  Otherwise, just cut off the bottom.
	
	// Use a background-layer and border-top, or alter the margin of Text?
	var contentHeight = pageHeight - footerHeight - headerHeight;
	var maxContentHeight = 380;
	var padding = 20;
//	var contentWidth = pageWidth;
//	var spaceOnLeft = 125;
	
//	content.style.width = contentWidth + "px";
	
	var txt = document.getElementById("textWrapper");
	txt.style.height = contentHeight + "px";
	
	if (contentHeight+padding > maxContentHeight && usePaddingTrick) {
		var diff = contentHeight - maxContentHeight + padding;
		content.style.height = (contentHeight - diff) + "px";
		content.style.borderTopWidth = diff + "px";
		txt.style.marginTop = "-" + diff + "px";
	} else {
		content.style.height = contentHeight + "px";
		content.style.borderTopWidth = "0";
		txt.style.marginTop = "0";
	}
}

function build () {
	var content = document.getElementById("content");
	var footer = document.getElementById("footer");
	var txt = document.getElementById("textWrapper");
	
	var borderStyle = "1px solid #900";
	
	content.style.padding = "10px 0";
	content.style.borderLeft = borderStyle;
	footer.style.borderTop = borderStyle;
	footer.style.borderLeft = borderStyle;
	rebuild();
}
//-->
