
(function($){
    $.fn.tooltip = function(options) {
        var fn = {
            ShowTooltip : function(e) {
                var text = $(this).data('tooltip');
                if (text.attr('class') != 'show-tooltip-text') return false;
                text.fadeIn().css({'top': e.pageY, 'left': e.pageX+10});
                return false;
            },
            HideTooltip : function(e) {
                var text = $(this).data('tooltip');
                if (text.attr('class') != 'show-tooltip-text') return false;
                text.hide();
            },
            MouseMoveTooltip : function(e) {
                var text = $(this).data('tooltip');
                if (text.attr('class') != 'show-tooltip-text') return false;
                text.hide().css({'top': e.pageY, 'left': e.pageX+10}).show();
            }
        };
        return this.each(function(index) {
            var span = ($('<span/>').attr('class', 'show-tooltip-text').html($(this).attr('title')));
            $(this).attr('title', '');
            $('body').append(span);
            $(this).data('tooltip', span);
        })
        .hover(fn.ShowTooltip, fn.HideTooltip)
        .mousemove(fn.MouseMoveTooltip);
    };
})(jQuery);

