var MaxWidth = 1000;
var MinWidth = 800;
var SliderWidth = 18;
var BarWidth = 180;
	
function calcLayoutWidth() {


	var LayoutWidth = MaxWidth;
	if(window.document.body.clientWidth < MaxWidth) {
		if(window.document.body.clientWidth > MinWidth)
			LayoutWidth = (window.document.body.clientWidth - SliderWidth);
		else
			LayoutWidth = MinWidth - SliderWidth;
	}	
	return LayoutWidth - 2;
}

function calcBrandingImageWidth() {

	var LayoutWidth = MaxWidth;

	if(window.document.body.clientWidth < 1020) {
		if(window.document.body.clientWidth > MinWidth)
			LayoutWidth = (window.document.body.clientWidth - SliderWidth);
		else
			LayoutWidth = MinWidth - SliderWidth;
	}
	
	return LayoutWidth - 2;
}

function calcContentAreaWidth() {

	if(document.getElementById('pnlRightBarPanel') == null & document.getElementById('pnlLeftBarPanel') == null)
	{
		return calcLayoutWidth();
	}
	
	if(document.getElementById('pnlRightBarPanel') == null)
	{
		return calcLayoutWidth() - BarWidth;
	}

	if(document.getElementById('pnlLeftBarPanel') == null)
	{
		return calcLayoutWidth() - BarWidth;
	}
	
	return calcLayoutWidth() - (2*BarWidth);
}


function calcContentAreaWidthFixed()
{

	if (document.getElementById('contentcenter') != null)
	{
		if(document.getElementById('pnlRightBarPanel') == null & document.getElementById('pnlLeftBarPanel') == null)
		{
			return MaxWidth;
		}
		
		if(document.getElementById('pnlRightBarPanel') == null)
		{
			return MaxWidth - BarWidth;
		}

		if(document.getElementById('pnlLeftBarPanel') == null)
		{
			return MaxWidth - BarWidth;
		}
		
		return MaxWidth - (2*BarWidth);
	}

	return MaxWidth - (2*BarWidth);
}


function adjustContentArea()
{
	if (document.getElementById('pagelayout') != null)
	{
	 	document.getElementById('pagelayout').style.width = calcLayoutWidth()+'px';
		document.getElementById('searchcontainer').style.left = (calcLayoutWidth() - 420)+'px';
		document.getElementById('contentcontainer').style.width = calcContentAreaWidth()+'px';
		if (document.getElementById('brandingimage') != null)
		{
			document.getElementById('brandingimage').style.width = calcBrandingImageWidth()+'px';
		}
	}
}		  


function adjustContentAreaFixed()
{
   var geckospace = 0;

   if (navigator.userAgent.toLowerCase().indexOf('gecko') != -1)
   {
		geckospace = 12;
   }
   
	if (document.getElementById('contentcenter') != null)
	{
		document.getElementById('contentcenter').style.width = calcContentAreaWidthFixed()- geckospace +'px';
		if (window.document.body.clientHeight > document.getElementById('contentfooter').offsetTop)
		{
		document.getElementById('contentcenter').style.height = (window.document.body.clientHeight - 200) +'px';
		}
	}
}		  


