function WindowWidth()
{
	if (window.innerWidth)
		return window.innerWidth;
		
	if (document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
		
	if (document.body.clientWidth)
		return document.body.clientWidth;
		
	if (document.body.offsetWidth)
		return document.body.offsetWidth;
}

function WindowHeight()
{
	if (window.innerHeight)
		return window.innerHeight;
		
	if (document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
		
	if (document.body.clientHeight)
		return document.body.clientHeight;
		
	if (document.body.offsetHeight)
		return document.body.offsetHeight;
}

function UpdateLayout()
{
	var mw = document.getElementById("MainWrapper");	
	var top = ((WindowHeight() - mw.offsetHeight) / 2) + "px";
	mw.style.marginTop = top;
}

function UpdateLayoutLoad()
{
	UpdateLayout();
	Element.removeClassName(document.body, "Loading");
}

var oldonload = window.onload;
if (typeof window.onload != 'function') { window.onload = UpdateLayoutLoad; }
else { window.onload = function() { if (oldonload) { oldonload(); } UpdateLayoutLoad(); } }

var oldonresize = window.onresize;
if (typeof window.onresize != 'function') { window.onresize = UpdateLayout; }
else { window.onresize = function() { if (oldonresize) { oldonresize(); } UpdateLayout(); } }