﻿(function($) {
    $.fn.extend({
        center: function(x, y) {
            // var options =  $.extend({transition:300, minX:0, minY:0}, options); 
            return this.each(function() {

                if (x == undefined) {
                    x = true;
                }

                if (y == undefined) {
                    y = true;
                }

                var $this = $(this);
                var $window = $(window);

                $this.css("position", "absolute");

                if (x) {
                    var left = ($window.width() - $this.outerWidth()) / 2 + $window.scrollLeft();
                    $this.css('left', left)
                }

                if (!y == false) {
                    var top = ($window.height() - $this.outerHeight()) / 2 + $window.scrollTop();

                    //top = top - ($this.outerHeight() / 2);
                    $this.css('top', top);

                    //alert($this.height());
                }

                // $(this).animate({ 
                //   top: (top > options.minY ? top : options.minY)+'px', 
                //   left: (left > options.minX ? left : options.minX)+'px' 
                // }, options.transition); 
                return $(this);
            });
        }
    });
})(jQuery); 



