/*In the event the user changes the dimensions of their browser window
call the 'findWindowDim' function*/

window.onresize = findWindowDim;

function findWindowDim(){

var dbcW = document.body.clientWidth;

var objLeft = document.getElementById('left');
var objMasthead = document.getElementById('masthead');
var objCenter = document.getElementById('center');
var objRight = document.getElementById('right');
var objLinks = document.getElementById('links');

var	leftWidth = document.getElementById('left').offsetWidth;
var	mastheadXPosPx = leftWidth+"px";
objMasthead.style.left = mastheadXPosPx;

var	centerXPosPx = leftWidth+"px";
objCenter.style.left = centerXPosPx;

/*Constructing the function to work with Netscape 6 (innerWidth)
and Netscape 7+, Mozilla 1.0.1+ and IE6+ (clientWidth).*/

//Determining browser type by functionality.
//Start IE5+, NS7 and Mozilla based on build 1.0.1

if (dbcW > 252){
function hideError() {
	return true;
	}
window.onerror = hideError;

	mastheadWidth = dbcW-leftWidth;
	mastheadWidthPx = mastheadWidth+"px";
	objMasthead.style.width = mastheadWidthPx;

	centerWidth = parseInt(.64*mastheadWidth);// OR parseInt((.52-leftWidth/dbcW)*100);
	centerWidthPx = centerWidth+"px";// OR centerWidthPct = centerWidth+"%";
	objCenter.style.width = centerWidthPx;//Pct;
	newCenterWidth = objCenter.offsetWidth;

	rightX = newCenterWidth+leftWidth;
	rightXPosPx = rightX+"px"
	objRight.style.left = rightXPosPx;
	objLinks.style.left = rightXPosPx;

	rightWidthPx = dbcW-leftWidth-newCenterWidth+"px";
	objRight.style.width = rightWidthPx;
	objLinks.style.width = rightWidthPx;

	}

var leftHeight = document.getElementById('left').offsetHeight;
var centerHeight = document.getElementById('center').offsetHeight;
var rightHeight = document.getElementById('right').offsetHeight;
var	linksHeight = document.getElementById('links').offsetHeight;
var mastheadHeight = document.getElementById('masthead').offsetHeight;

var objFooter = document.getElementById('footer')

if (document.body.clientHeight > 200){

function hideError() {
	return true;
	}
window.onerror = hideError;

	linksY = rightHeight + mastheadHeight;
	linksYPosPx = linksY+"px";
	objLinks.style.top = linksYPosPx;

	}
//End IE5+, NS7, Mozilla 1.0.1

//Start NS6 (Mozilla 0.9.4) and disinclude NS7.0 and Mozilla 1.0.1 and earlier.

var wiW = window.innerWidth;
if (window.setCursor && (wiW >252)){
function hideError() {
	return true;
	}
window.onerror = hideError;

	mastheadWidth = wiW-leftWidth;
	mastheadWidthPx = mastheadWidth+"px";
	objMasthead.style.width = mastheadWidthPx;

	centerWidth = parseInt(.64*mastheadWidth);
	centerWidthPx = centerWidth+"px";
	objCenter.style.width = centerWidthPx;
	newCenterWidth = objCenter.offsetWidth;

	rightX = newCenterWidth+leftWidth;
	rightXPosPx = rightX+"px"
	objRight.style.left = rightXPosPx;
	objLinks.style.left = rightXPosPx;

	rightWidthPx = wiW-leftWidth-centerWidth-20+"px";
	objRight.style.width = rightWidthPx;
	objLinks.style.width = rightWidthPx;

	}

if (window.setCursor && (window.innerHeight > 200)){

function hideError() {
	return true;
	}
window.onerror = hideError;

	linksY = rightHeight + mastheadHeight;
	linksYPosPx = linksY+"px";
	objLinks.style.top = linksYPosPx;
	
	}
//End NS6


/*Position footer to tallest column.*/
if ((centerHeight + mastheadHeight > leftHeight) && (centerHeight > rightHeight + linksHeight)){
	footerTop = mastheadHeight + centerHeight;
	footerTopPx = footerTop+"px"
	objFooter.style.top = footerTopPx;
	}
else if ((leftHeight > centerHeight + mastheadHeight) && (leftHeight > rightHeight + mastheadHeight + linksHeight)){
	footerTop = leftHeight;
	footerTopPx = footerTop+"px"
	objFooter.style.top = footerTopPx;	
	}
else {
	footerTop = mastheadHeight + rightHeight + linksHeight;
	footerTopPx = footerTop+"px"
	objFooter.style.top = footerTopPx;	
	}
}