function fixLayout()
{
	var cont = document.getElementById("page-wrapper");
	var contHeight = cont.offsetHeight;
	var newTopMargin;
	wHeight = window.innerHeight;

	if (document.all && !window.opera) {
		wHeight = document.documentElement.clientHeight;
	}
		var temp = wHeight - contHeight;
		if (temp > 0)
	{
		cont.style.marginTop = (wHeight - contHeight) / 2 + "px";
		newTopMargin = (wHeight - contHeight) / 2;
	}
	else {
		cont.style.marginTop = "0px";
		newTopMargin = 0;
	}
	
	$.ajax({
	  type: "GET",
	  url: "/set-top-margin/" + newTopMargin + "/",
	  dataType: "script"
	});
	
}
if (window.addEventListener){
	window.addEventListener("resize", fixLayout, false);
	window.addEventListener("load", fixLayout, false);
}
else if (window.attachEvent){
	window.attachEvent("onresize", fixLayout);
	window.attachEvent("onload", fixLayout);
}