﻿jQuery.fn.center = function (widthObject) {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    var w;
    if (widthObject != null)
        w = $(widthObject).width();        
    else
        w = $(window).width();
    this.css("left", ( w - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}
