$(document).ready(function() {

	jQuery.fn.centerScreen = function(loaded) {
		var obj = this;
		var windowheight = $(window).height() / 2 - this.height() / 2;
		/* If the window is too short, force it to center at a reasonable value */
		var minheight = 18;
		if (windowheight < minheight) {
			windowheight = minheight;
		}

		if (!loaded) {
			obj.css('top', windowheight);
			$(window).resize(function() { 
				obj.centerScreen(!loaded); 
			});
		} else {
			obj.stop();
			obj.animate({ top: windowheight }, 500, 'easeInOutCubic'); 	
		}
	}
});