(function ($) {
	$.fn.align = function(type) {
		switch(type) {
			case 'h':
				return this.each(function(){
					$(this).css({
						marginLeft:'-' + $(this).outerWidth() / 2 + 'px',
						left:'50%',
						position:'absolute'
					});
					$(this).parent().css('position','relative')
				});
				break;
			case 'v':
				return this.each(function(){
					$(this).css({
						marginTop:'-' + $(this).outerHeight() / 2 + 'px',
						top:'50%',
						position:'absolute'
					});
					$(this).parent().css('position','relative')
				});
				break;
			case 'both':
				return this.each(function(){
					$(this).css({
						marginLeft:'-' + $(this).outerWidth() / 2 + 'px',
						left:'50%',
						marginTop:'-' + $(this).outerHeight() / 2 + 'px',
						top:'50%',
						position:'absolute'
					});
					$(this).parent().css('position','relative')
				});

		}

	};
})(jQuery);
