(function (jQuery) { 
jQuery.fn.vAlign = function() { 
return this.each(function(i){ 
var pct = 50; // vertical alignment percentage 
jQuery(this).css("top", pct + "%"); // Reset position to standard 
var md = 0; // minimum position in pixels from top 
var ctr = 0; // 0: start content from middle // 1: center content in the middle 
var h = jQuery(this).height(); 
var oh = jQuery(this).outerHeight(); 
var mt = (h + (oh - h)) / 2; 
var os = jQuery(this).position(); 
if (ctr == 1) { 
jQuery(this).css("margin-top", "-" + mt + "px"); 
var md = md + mt; 
} 
if (os.top > md) { 
jQuery(this).css("top", pct + "%"); 
} else { 
jQuery(this).css("top", md + "px"); 
} 
jQuery(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);
