window.addEvent("domready", function () 
{
	function ResizeHeight() 
	{
		var window_h = window.getHeight();
		var original = 700;
		var minimum = 500;
		var offset = 20;

		if (window_h < original + offset)
		{
			var new_height = Math.min(Math.max(window_h - offset, minimum), original);

			AttachStyle("#wrapper_outer","height: " + new_height + "px");
			AttachStyle(".column","height: " + Math.max(new_height, minimum) + "px");
			AttachStyle(".track","height: " + Math.max(new_height, minimum) + "px");
			AttachStyle(".menu_item","height: " + Math.max(new_height, minimum) + "px");
			AttachStyle(".menu_item a","height: " + Math.max(new_height, minimum) + "px");

			// get padding of page content
				var pc = $$("div.page_content")[0];
				var pt = parseInt(pc.getStyle("padding-top")) || 0;
				var pb = parseInt(pc.getStyle("padding-bottom")) || 0;

			var new_height_page_content = new_height - pt - pb;

			AttachStyle(".page_content","height: " + new_height_page_content + "px");

			// save it so it can be done in PHP
				/*var myCookie =*/ 
				Cookie.write("JAF_SCREEN_HEIGHT", new_height + "|" + new_height_page_content, { "duration" : 0});

		}
		
	}

	if (!Cookie.read("JAF_SCREEN_HEIGHT")) ResizeHeight();

	window.addEvent("resize", ResizeHeight);

});
