//Copyright (c) 2008 Joshua Napoli
//All rights reserved.

//If the window is taller than the body, then center it, horizontally.
function vCenterBody()
{
	if(document.viewport.getHeight() < $$('body')[0].getHeight())
	{
		document.body.setStyle({'top':'0', 'marginTop':'0'});
	}
	else
	{
		/*We prefer to use 'top: 50%; margin-top: -height/2', since this keeps the page centered
		even while the user changes the size of the page. But IE 8 beta 1 does not use the top/left
		properties of the body element, so we special-case it. */
		if(Prototype.Browser.IE)
		{
			document.body.setStyle(
				{'top':'0'
				,'marginTop' : (document.viewport.getHeight()-document.body.getHeight())/2+'px'});
		}
		else
		{
			document.body.setStyle(
				{'top' : '50%'
				,'marginTop' : -document.body.getHeight()/2+'px'});
		}
	}
}

Event.observe(window, 'load', function() {
	vCenterBody();
	Event.observe(window, 'resize', vCenterBody);
});