(function($)  
{  
    $.fn.centerElementWithTop = function(topY) {
        return this.each(function()  
        {  
            var el = this;
            $(el).remove().appendTo("body")  
                    .wrap("<div style='position:absolute;left:50%;top:0px;width:1px;height:1px;'></div>")  
                    .css({position: 'relative', left: el.offsetWidth / -2 + "px", top: topY + "px"});  
        });  
    };  

})(jQuery); 
