jQuery.fn.center = function() {
    var t = jQuery(this);
    
    var h = t.height(),
        w = t.width(),
        windowWidth      = $.browser.opera ? self.innerWidth: $(window).width(),
        windowHeight     = $.browser.opera ? self.innerHeight : $(window).height(),
        windowScrollTop  = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop),
        windowScrollLeft = self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
    
    var top  = (Math.round((windowHeight - h) / 2)) + windowScrollTop;
    var left = (Math.round((windowWidth  - w) / 2)) + windowScrollLeft;
    if (h > windowHeight) {
        top = 10;
    }
    t.css({
        left: left,
        top: top,
        position: 'absolute',
        display: 'block'
    });
};
