<!-- Centre site start -->
(function($) {
    $.fn.vAlign = function() {
        return this.each(function(i) {
            var h = $(this).height();
            var oh = $(this).outerHeight();
            var mt = (h + (oh - h)) / 2;
            $(this).css("margin-top", "-" + mt + "px");
            $(this).css("top", "50%");
            $(this).css("position", "absolute");
        });
    };
})(jQuery);

(function($) {
    $.fn.hAlign = function() {
        return this.each(function(i) {
            var w = $(this).width();
            var ow = $(this).outerWidth();
            var ml = (w + (ow - w)) / 2;
            $(this).css("margin-left", "-" + ml + "px");
            $(this).css("left", "50%");
            $(this).css("position", "absolute");
        });
    };
})(jQuery);

$(document).ready(function() {
    CentreSite(true);
    $("div#container").fadeIn('medium');
});

$(window).resize(function() {
    CentreSite(false);
});

function CentreSite(init) {
	var ww = $(window).width();
	var wh = $(window).height();
	var cw = $('div#container').width();
	var ch = $('div#container').height();
	
	if (parseInt(ww) > parseInt(cw)) {
		if (init || parseInt($("div#container").css('left')) == 0) {
			$("div#container").hAlign();
		}
	} else {
		if (init || $("div#container").css('left') == '50%') {
			$("div#container").css({'margin-left': 0, 'left': 0, 'position': 'absolute'});
		}
	}

	if (parseInt(wh) > parseInt(ch)) {
		if (init || parseInt($("div#container").css('top')) == 0) {
			$("div#container").vAlign();
		}
	} else {
		if (init || $("div#container").css('top') == '50%') {
			$("div#container").css({'margin-top': 0, 'top': 0, 'position': 'absolute'});
		}
	}

}
<!-- Centre site end -->
