/**
 * @author Alexandre Magno & Chris Barrett
 * @desc Center a element with jQuery
 * @version 1.0
 * @example
 * $("element").center();
 * @license free
 * @contribution Paulo Radichi
 *
 */
jQuery.fn.center = function(params) {

		var options = {

			vertical: true,

		}
		op = jQuery.extend(options, params);

   return this.each(function(){

		//initializing variables
		var $self = jQuery(this);
		//get the dimensions using dimensions plugin
		var height = $self.height();
		var htmlheight = $(window).height();
		//get the paddings
		var paddingTop = parseInt($self.css("padding-top"));
		var paddingBottom = parseInt($self.css("padding-bottom"));
		//get the borders
		var borderTop = parseInt($self.css("border-top-width"));
		var borderBottom = parseInt($self.css("border-bottom-width"));
		//get the media of padding and borders
		var mediaBorder = (borderTop+borderBottom)/2;
		var mediaPadding = (paddingTop+paddingBottom)/2;
		// get the half minus of width and height
		var halfHeight = (htmlheight-(height+mediaPadding+mediaBorder))/2;
		// initializing the css properties
		var cssProp = {
		};

		if(op.vertical) {
			cssProp.marginTop = halfHeight;
		}

		//aplying the css
		$self.css(cssProp);


   });

};
