/*#########################################################################
#
#   name :       SX.css
#   desc :       Javascript collection (incliding Macromedia and Tim Funct()
#   categorie :  JavaScript
#   ID :  	 $Id: SX.js 1061 2007-08-30 21:19:44Z cl $
#
#   copyright:   See licence.txt for this script licence
#########################################################################*/

function getWindowSize() 
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
	 	myHeight = window.innerHeight;
	 	myWidth = window.innerWidth;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return new Array(myWidth,myHeight);
}


function blockPositioning()
{
	var contentBlockID 	= "pageContent";
	var menuBlockID 		= "MenuBlock";
	var MenuBlockRightID	= "MenuBlockRight";
	var FooterBlockID		= "FooterBandeau";
	var windowSize 		= getWindowSize();
	
	var tagContent 		= document.getElementById(contentBlockID);
	var tagMenu 		= document.getElementById(menuBlockID);
	var tagMenuRight		= document.getElementById(MenuBlockRightID);
	var tagFooter		= document.getElementById(FooterBlockID);
	
	if (tagContent.offsetWidth) 
	{ 
		var decalContentLeft 	=  Math.round((windowSize[0] - tagContent.offsetWidth)/2);
		var decalContentTop 	=  Math.round((windowSize[1] - tagContent.offsetHeight)/2);
		tagContent.style.marginLeft = decalContentLeft+"px";
		tagContent.style.marginTop = decalContentTop+"px";
		
		if (tagMenu) 
		{ 
			var decalMenuLeft 	=  decalContentLeft;
			var decalMenuTop 	=  decalContentTop + Math.round((tagContent.offsetHeight - tagMenu.offsetHeight)/2);
			tagMenu.style.marginLeft = decalMenuLeft+"px";
			tagMenu.style.marginTop = decalMenuTop+"px";
		}
		if (tagMenu && tagMenuRight) 
		{ 
			var decalMenuRightLeft 	=  decalContentLeft + tagContent.offsetWidth - tagMenuRight.offsetWidth;
			var decalMenuRightTop 	=  decalContentTop + Math.round((tagContent.offsetHeight - tagMenuRight.offsetHeight)/2);
			tagMenuRight.style.marginLeft = decalMenuRightLeft+"px";
			tagMenuRight.style.marginTop = decalMenuRightTop+"px";
		}
		if (tagFooter) 
		{ 
			var decalFooterLeft 	=  decalContentLeft + Math.round((tagContent.offsetWidth - tagFooter.offsetWidth)/2);
			var decalFooterTop 	=  decalContentTop + tagContent.offsetHeight - tagFooter.offsetHeight;
			tagFooter.style.marginLeft = decalFooterLeft+"px";
			tagFooter.style.marginTop = decalFooterTop+"px";
		}
	}
}
