Element.observe(window,'load',sitePositioning);

function sitePositioning(){

	if($('rightContent') == null)
		return false;

	var obj = $('contentMainContainer');
	
	var allContentsArr = Element.select(obj, "div.csc-default");
	allContentsArr[0].style.marginBottom = "0px";
	allContentsArr[0].style.paddingBottom = "0px";
	allContentsArr[0].style.backgroundColor = 'transparent';
	allContentsArr[0].style.border = 'none';
	allContentsArr[0].style.boxShadow = 'none';

	var contObjHeight = 0;
	if($("contactBox") != null){
		var contObj = Element.up('contactBox');
		contObjHeight =  Element.getHeight(contObj) + parseInt(Element.getStyle('rightContent','margin-top'));
	}else{
		$('rightContent').style.marginTop = '0px';
	}

	var contentHeight = Element.getHeight(obj)- parseInt(Element.getStyle(obj,'border-top-width')) - parseInt(Element.getStyle(obj,'border-bottom-width'));
	$('menuLeftContainer').style.height = contentHeight+'px'; 
		$('rightContent').style.height = (contentHeight-contObjHeight)+'px'; 

	//if rightcolumn > contentcolumn
	if($("contactBox") != null && (contentHeight+contObjHeight) > Element.getHeight(obj)){
		obj.style.height = (Element.getHeight(contObj)+contObjHeight)+'px';
	}else if((contentHeight+contObjHeight) > obj.getHeight()){
		obj.style.height = $('rightContent').getHeight()+'px';
	}



	//footer
	var paddingLeft = 20;
	var footerWidth = parseInt(Element.getWidth('footerContainer')) - parseInt(Element.getStyle(obj,'border-left-width')) - parseInt(Element.getStyle(obj,'border-right-width')) - paddingLeft;

	var footerLayer1 = $$('li.subLayer1');

	var eachFooterLiWidth = footerWidth / footerLayer1.length;

	footerLayer1[0].style.paddingLeft = paddingLeft+'px';
	for(i=0;i<footerLayer1.length;i++){
		  footerLayer1[i].style.width = eachFooterLiWidth+"px";
	}

	//no background on references
	if($("edx_referencContainer") != undefined){
		//var allContentsArr = $$("div.csc-default");
		/*var allContentsArr = Element.select(obj, "div.csc-default");
		allContentsArr[0].style.marginBottom = "0px";
		allContentsArr[0].style.paddingBottom = "0px";
		for(var i=0;i<=allContentsArr.length-1;i++){
			allContentsArr[i].style.backgroundColor = 'transparent';
			allContentsArr[i].style.border = 'none';
			allContentsArr[i].style.boxShadow = 'none';
		}*/
		if(typeof positioning4References == 'function')
			positioning4References();
	}

	if(Element.getHeight('menuLeftContainer') > Element.getHeight('contentMainContainer'))
		$('contentMainContainer').style.height = 'auto';

	if(Element.getHeight('contentMainContainer') > Element.getHeight('contentRightContainer')){
		$('rightContent').style.height = (Element.getHeight('contentMainContainer') - Element.getHeight('contactBox'))+'px';
		$('menuLeftContainer').style.height = Element.getHeight('contentMainContainer')+'px';
	}
}

	function positioning4References(){

		if($("contactBox") != null && ((Element.getHeight(Element.up('contactBox'))+Element.getHeight('rightContent')) > Element.getHeight('contentMainContainer'))){
			var paddingTop = parseInt(Element.getStyle('contentMainContainer','padding-top'));
			var paddingBottom = parseInt(Element.getStyle('contentMainContainer','padding-bottom'));
			$('contentMainContainer').style.height = (Element.getHeight(Element.up('contactBox'))+Element.getHeight('rightContent') -paddingTop - paddingBottom)+'px';
			$('menuLeftContainer').style.height = (Element.getHeight(Element.up('contactBox'))+Element.getHeight('rightContent'))+'px';
			return false;
		}

		if(((Element.getHeight(Element.up('contactBox'))+Element.getHeight('rightContent')) > Element.getHeight('contentMainContainer'))){
			var borderRightTop = parseInt(Element.getStyle('rightContent','border-top-width'));
			var borderRightBottom = parseInt(Element.getStyle('rightContent','border-bottom-width'));
			$('contentMainContainer').style.height = Element.getHeight('rightContent')+'px';
			$('menuLeftContainer').style.height = Element.getHeight('rightContent')+'px';
			return false;
		}



		var contentHeight = Element.getHeight('contentMainContainer');

		$('menuLeftContainer').style.height = contentHeight+'px';

		if($("contactBox") != null){
			var contObj = Element.up('contactBox');
			var borderRightTop = parseInt(Element.getStyle('rightContent','border-top-width'));
			var borderRightBottom = parseInt(Element.getStyle('rightContent','border-bottom-width'));
			contObjHeight = contObj.getHeight() + parseInt(Element.getStyle('rightContent','margin-top'));
			$('rightContent').style.height = (contentHeight - contObjHeight - borderRightTop - borderRightBottom)+'px';
		}else{
			$('rightContent').style.marginTop = '0px';
			$('rightContent').style.height = contentHeight+'px';
		}
	
	}


