jQuery center object vertical and horizontal

#center#jquery#plugin
$(".classname").centerMiddle();
;(function($, win) {
  $.fn.centerMiddle = function(options) {
	  
	  // Defaults
		var settings = $.extend({
			'parentRelative': window,
			'marginLeft': null, 
			'marginRight':null,
			'marginTop' : null,
			'position' : 'absolute'
		}, options );
	  
     return this.each(function(i,el){
		
       function crml(){
		   var parent = $(settings.parentRelative);
		   var parentHeight = $(parent).innerHeight();
		   var parentWidth = $(parent).innerWidth();
		   
		   parent.css({
				position : 'relative'
			});
		   
		   // Clear element margin and padding to calculate actual dimensions
			$(el).css({
				margin : '',
				padding : '',
				display : 'inline-block'
			});
		   
		   var contentWidth = $(el).outerWidth(); 
		   var contentHeight = $(el).outerHeight();  
		   
		   var set_left = (parentWidth - contentWidth - settings.marginLeft - settings.marginRight) / 2;
		   var set_top = (parentHeight - contentHeight) / 2; 
		   
			return $(el).css({
				'position' : settings.position,
				'left' : set_left,
				'top' : set_top,
				'margin-left' : settings.marginLeft,
				'margin-right' : settings.marginRight,
				'margin-top' : settings.marginTop
			}); 
       } crml();
       $(win).on('resize scroll', crml);
     });
  };
}(jQuery, window));