function adjustLayout()
{
	xHide("footer");
	var minHeight = 300;

	//Get natural heights
	var cHeight = xHeight("centercontent");
	var lHeight = xHeight("leftcontent");
	var rHeight = xHeight("rightcontent");
	
	var maxHeight = Math.max(minHeight, Math.max(cHeight, Math.max(lHeight, rHeight)));

	xHeight("center", maxHeight);
	xHeight("left", maxHeight);
	xHeight("right", maxHeight);

	setupHeader();
	xShow("footer");

}


function setupHeader()
{
	var minTopHeight = 100;
//	var lWidth = xWidth("picture2");
	var tWidth = xWidth("top");
	var ttWidth = xWidth("toptext");

//	alert("W p2: " + xWidth("picture2"));
	xLeft("picture1", 20);
	var p1Right = xLeft("picture1") + xWidth("picture1");

//	xLeft("picture2", tWidth/2 - lWidth/2);
	xLeft("picture2", p1Right + 20);

	var p2Right = xLeft("picture2") + xWidth("picture2");
	var ttWidth = (tWidth - p2Right) * 0.8;
	var ttRightM = (tWidth - p2Right) * 0.1;

	xWidth("toptext", ttWidth);
	xLeft("toptext", tWidth - ttWidth - ttRightM );

	var ttHeight = xHeight("toptext");
	var tHeight = xHeight("top");
	
	if (ttHeight + 5 > tHeight)
	{
//		alert("Heights need adjusting!");
		xHeight("top", ttHeight + 5);
		xTop("left", ttHeight + 5);
		xTop("right", ttHeight + 5);	
	} else
	{
		if (ttHeight + 5 < tHeight)
		{
			if (ttHeight + 5 > minTopHeight )
			{
				xHeight("top", ttHeight + 5);
				xTop("left", ttHeight + 5);
				xTop("right", ttHeight + 5);
			} else
			{
				xHeight("top", minTopHeight );
				xTop("left", minTopHeight );
				xTop("right", minTopHeight );	
			}		
		}
	}
}


