/**
 * Help Bubble
 * Thu, 9 Oct 2008 21:36:22 GMT
 */

var helpBubble = 
{
    init: function()
    {           
        $("img.help").click(helpBubble.show);
    },
    
    bubbleExists: function()
    {
        return $("div#helpbubble").length > 0;
    },
    
    createBubble: function()
    {
        $("body").append("<div id=\"helpbubble\" class=\"bubble\"><div class=\"bubbletop\"></div><div class=\"bubblebottom\">Click to close.</div></div>");
        
        $("div#helpbubble").click(function()
        {
            $(this).css("display", "none");
        });
    },
    
    show: function(event)
    {
        if(!helpBubble.bubbleExists())
        {
            helpBubble.createBubble();
        }
        
        else
        {
            $("div#helpbubble div.bubbletop").empty();
        }
        
        $("div#helpbubble div.bubbletop").append($(this).next().clone(true).removeClass("helptext"));
        
        $("div#helpbubble").css
        ({
            top: event.pageY - $("div#helpbubble").height(),
            left: event.pageX + 12,
            display: "block"
        });
    }
}

$(document).ready(helpBubble.init);