1. (function($) {
  2.  
  3.     $.fn.showhide = function(options) {
  4.    
  5.         var defaults = {
  6.                 appear: true,
  7.                 speed: 500
  8.             },
  9.             settings = $.extend({}, defaults, options);
  10.        
  11.         this.each(function() {
  12.        
  13.             var $this = $(this),
  14.                 elementWidth = $this.width(),
  15.                 elementHeight = $this.height(),
  16.                 newWidth = 0,
  17.                 newHeight = 0,
  18.                 marginX = Math.floor(elementWidth / 2),
  19.                 marginY = Math.floor(elementHeight/ 2);
  20.                
  21.             if(settings.appear) {
  22.            
  23.                 console.log(elementWidth + ' ' + elementHeight + ' ' + marginX + ' ' + marginY);
  24.            
  25.                 $this.css({ width: newWidth + 'px', height: newHeight + 'px', margin: marginY + 'px ' + marginX + 'px' });
  26.                 $this.animate({ width: elementWidth + 'px', height: elementHeight + 'px', margin: '0px', opacity: 'show' }, settings.speed);
  27.            
  28.             } else {
  29.            
  30.                
  31.            
  32.             }
  33.        
  34.         });
  35.        
  36.         return this;
  37.    
  38.     }
  39.  
  40. })(jQuery);