(function () {
    var tooltip;
    
    jQuery(function () {
        tooltip = jQuery("<div />")
            .attr('id', 'tooltip')
            .css({display: 'none', position: 'absolute'});            
        jQuery('body').append(tooltip);
    })
    
    jQuery.fn.tooltip = function () {
        var elements = this;
        jQuery(function () {
            elements.each(function () {
                jQuery(this)
                    .attr('_title', jQuery(this).attr('title'))
                    .removeAttr('title')
                    .mouseover(function () {
                        tooltip.text(jQuery(this).attr('_title')).show();
                    })
                    .mouseout(function () {
                        tooltip.hide();
                    })
                    .mousemove(function (event) {
                        tooltip.css({
                            top:    event.pageY + 10 + 'px',
                            left:   event.pageX + 10 + 'px'
                        });
                    })
            })
        })
        return this;
    }
})();