(function($) {
	$.fn.vCenter = function(refHeight) {
		return this.each(function(i) {
			var $that = $(this);

			function centerIt($elm) {
				var ah = $elm.height();
				if (typeof(refHeight) === 'undefined') refHeight = $elm.parent().height();
				var mh = Math.ceil((refHeight - ah) / 2);
				$elm.css('margin-top', mh);
			}

			if ($that.is("img")) {
				$(window).load(function() { centerIt($that); });
			} else {
				centerIt($that);
			}
		});
	};
})(jQuery);
