// JavaScript Document
function adjustToContent(){
	//<<<<<<<<<< If body has a style of "fixedwidth" do not adjust the width of the page >>>>>>>>>>>>>>>
	//Use this style as a manual over-ride and set width with a CSS link AFTER layout.css link in basicHeadTags.shtml include
	var bodyClass=document.getElementsByTagName("body")[0].className;
	if (bodyClass.indexOf("fixedwidth")==-1){//if multiple classes, check for occurance of "fixedwidth"
		//<<<<<<<<<Adjust page width to main content>>>>>>>>>>>>>>>
		var minWidth = 924;//Minimum writeable page width to accomodate header and top nav can be ADJUSTED HERE
		var mainMargin = 80;//ADJUST HERE for main content left and right margin
		//(mainContainer left and right margin in layout.css are really just noscript settings)
		var shadowWidth = document.getElementById("shadowLeft").offsetWidth;
		var mainContent = document.getElementById("mainContainer");
		var mainWidth = mainContent.offsetWidth;
		var rightWidth = document.getElementById("rightContainer").offsetWidth;
		if(mainWidth > 700){//For very wide pages (ADJUST CUTOFF HERE), cut the margins for the main content in half.
			mainMargin /=2;		
		}
		var pW = mainWidth+rightWidth+mainMargin*2;
		if(pW >= minWidth-shadowWidth*2){//If main content is too wide for min width
			document.getElementById("pageWrapper").style.width = (pW+shadowWidth*2)+"px";
			document.getElementById("pageContainer").style.width = (pW)+"px";
			mainContent.style.marginLeft=mainMargin+"px";
			mainContent.style.marginRight=mainMargin+"px";			
		}else{
			document.getElementById("pageWrapper").style.width = minWidth+"px";
			document.getElementById("pageContainer").style.width = (minWidth-shadowWidth*2)+"px";	
			var autoMargin = (minWidth-shadowWidth*2-mainWidth-rightWidth)/2;
			mainContent.style.marginLeft = autoMargin+"px";
			mainContent.style.marginRight = autoMargin+"px";
		}
	}
	//<<<<<<<<<<<<<<<<<<<Adjust shadow height>>>>>>>>>>>>>>>>>>>>>>>>>>>>
	var leftShadow = document.getElementById("shadowLeft").getElementsByTagName("img")[0];
	var rightShadow = document.getElementById("shadowRight").getElementsByTagName("img")[0];
	var pageHeight = document.getElementById("pageWrapper").offsetHeight;
	leftShadow.height = pageHeight;
	rightShadow.height = pageHeight;
}