$(document).ready(function(){
    $("div.question fieldset").hover(
        function (){
            // Grab the span - get the title and blank
            span = $(this).find("legend span");
            this.tooltipText = span[0].title;
            tooltipTitle = $(span[0]).text();
            $(span[0]).removeAttr("title");
            // Get the offset of the fieldset so we can position the tooltip
            offset = $(this).offset();
            newTop = offset.top - 20;
            newLeft = offset.left;
            tt = $('<div class="rating_tooltip"><strong>' + tooltipTitle + '</strong>' + '<p>'+this.tooltipText + '</p></div>');
            $(tt).css({
                top: newTop + 'px',
                left: newLeft + 'px'
            });
            // Create the tooltip and display it
            $(this).append(tt)
            $(this).css( 'border-bottom-color', '#ff0000' );
            tt.fadeIn('fast');
        },
        function (){
            // Restore the title to the span
            $(this).find("legend span").attr("title", this.tooltipText);
            // Remove the tooltip
            tt = $(this).find("div.rating_tooltip");
            $(this).css( 'border-bottom-color', '#cccccc' );
            tt.fadeOut('fast', function(){ $(this).remove() });
        }
    );
}); // close document.ready
