function getStyleInt(element, style)
{
	var i = parseInt(element.getStyle(style));
	return isNaN(i) ? 0 : i;
}

var resizeDIVs = function()
{
	if (Prototype)
	{
		var viewportHeight = document.viewport.getHeight() - 55;
		var footer = $("footer");
		var page_margins = $("page_margins");
		var myBody = $("myBody");
		var maxColHeight = 0;
		var col1 = $("col1");
		var col2 = $("col2");
		var col3 = $("col3");

		if (col1) maxColHeight = Math.max(maxColHeight, col1.getHeight());
		if (col2) maxColHeight = Math.max(maxColHeight, col2.getHeight());
		if (col3) maxColHeight = Math.max(maxColHeight, col3.getHeight());
		if (col1) col = col1;
		if (!col) col = col2;
		if (!col) col = col3;
		if ($("col3_content")) $("col3_content").setStyle({height:(maxColHeight)+"px"});
		if (footer && myBody && page_margins && col)
		{
			footer.absolutize();
			var footerTop = getStyleInt(footer, "top");
			var footerHeight = footer.getHeight();
			var myBodyHeight = myBody.getHeight();			
			var topOffset = getStyleInt(page_margins, "marginTop") + getStyleInt(myBody, "marginTop") + getStyleInt(myBody, "paddingTop");
			var bottomOffset = getStyleInt(page_margins, "marginBottom") + getStyleInt(myBody, "marginBottom") + getStyleInt(myBody, "paddingBottom");
			if (myBodyHeight < viewportHeight && footerTop+footerHeight < viewportHeight-bottomOffset) 
			{
				var height = viewportHeight - bottomOffset - topOffset;
				$("page").setStyle({height:height+"px"});		
				myBody.setStyle({height:height+"px"});
				var main = $("main");
				main.absolutize();
				var mainTop = getStyleInt(main, "top");
				col.setStyle({height:(viewportHeight-mainTop+ bottomOffset-footerHeight)+"px"});
				if ($("col3_content")) $("col3_content").setStyle({height:(viewportHeight-mainTop+ bottomOffset-footerHeight)+"px"});
				main.relativize();
			}
			footer.relativize();
		}
	}
}

Event.observe(window, 'load', resizeDIVs);




