/**
 * @desc Center a element with jQuery in window
 * @version 1.0
 * @example
 * $("element").center();
 *
 */
jQuery.fn.center = function() {

   return this.each(function(){
		//initializing variables
		var $self = jQuery(this);
		var pozX = jQuery(document).scrollLeft() + 
      ((jQuery(window).width() - $self.width()) / 2);
    if (pozX<0) pozX = 0;
    var pozY = jQuery(document).scrollTop() + 
      ((jQuery(window).height() - $self.height()) / 2);
    if (pozY<0) pozY = 0;
    // initializing the css properties
		var cssProp = {
			position: 'absolute',
			z_index: 10000,
			top: pozY,
			left: pozX
		};
		//aplying the css
		$self.css(cssProp);
   });

};
