/*
 *JQuery center
 *
 *@author Alexey playboyko Boyko (playboyko.spb@gmail.com)
 *@date 2009-02-10
 *@version 1.0
 */

; ( function($) {
    
    $.fn.center = function( onResize ) {
        var resize = onResize ? onResize : true;
        var self   = this;
        if( resize ) {
            $(window).resize( function() {
                self.each( center );
            });
        }
        return this.each( center );
    }
    function center() {
        var $this = $(this);
        var left = $(window).width()/2;
        var top  = $(window).height()/2;
        
        left -= $this.width()/2;
        top  -= $this.height()/2;
        
        $this.css({top: top, left: left});
    }
})(jQuery);