/*******************************************************************************
* Copyright (c) 2008. Fusework Studios, a Division of Rutter Communications	   *
*						Network LLC. All rights reserved.					   *
*******************************************************************************/

/*******************************************************************************
* The following lines of code layout the home page based on the client's 	   *
* browser size and settings.												   *
*******************************************************************************/

var maxWidth = 481;
var currWidth = maxWidth;
var bodyWidth = 940;

var estWidth = (parseInt((Math.round((document.body.clientWidth/2)-(bodyWidth/2)))/20) * 20) + 1;

if (document.body.clientWidth < bodyWidth)
	estWidth = 1;
else
	estWidth = (parseInt((Math.round((document.body.clientWidth/2)-(bodyWidth/2)))/20) * 20) + 1;

if (estWidth != currWidth)
{
	if (estWidth < 1 || document.body.clientWidth < bodyWidth )
		estWidth = 1;
		
	if (estWidth > maxWidth)
		estWidth = maxWidth;
		
	currWidth = estWidth;
}	
	
document.getElementById("body-shim").style.width = currWidth + "px";

/*
document.getElementById("page-body").style.top = 0;
document.getElementById("page-body").style.left = (parseInt((Math.round((document.body.clientWidth/2)-(currWidth/2)))/20) * 20) + 20;
alert((parseInt((Math.round((document.body.clientWidth/2)-(currWidth/2)))/20) * 20) + 20);
//document.getElementById("page-body").style.left = Math.round((document.body.clientWidth/2)-(currWidth/2));
*/

// this event will execute in the event the window is resized
window.onresize = function()
{
	if (document.body.clientWidth < bodyWidth)
		estWidth = 1;
	else
		estWidth = (parseInt((Math.round((document.body.clientWidth/2)-(bodyWidth/2)))/20) * 20) + 1;
	
	if (estWidth != currWidth)
	{
		if (estWidth < 1 )
			estWidth = 1;
			
		if (estWidth > maxWidth)
			estWidth = maxWidth;
			
		currWidth = estWidth;
	}	
		
	document.getElementById("body-shim").style.width = currWidth + "px";
	/*
	document.getElementById("page-body").style.top = 0;
	document.getElementById("page-body").style.left = (parseInt((Math.round((document.body.clientWidth/2)-(currWidth/2)))/20) * 20) + 20;
	alert((parseInt((Math.round((document.body.clientWidth/2)-(currWidth/2)))/20) * 20) + 20);
	//document.getElementById("page-body").style.left = Math.round((document.body.clientWidth/2)-(currWidth/2));
	*/
}
