window.pemco = window.pemco || {};

/*
Widget to display the twitter feed / followers
*/
(function($) {
    var pub = window.pemco.tooltip = {};

    var transSpeed          = 300;

    var tipExpanded         = [];

    pub.create = function(id, containerSelector, tipText)
    {
        tipExpanded[id]     = false;

        $(containerSelector).html( "<div class='tooltip-trigger'><img src='images/help-mark-off.gif' border='0' onmouseover=\"pemco.tooltip.show('"+id+"');\" onmouseout=\"pemco.tooltip.hide('"+id+"');\" /></div>"
                                 + "<div id='tooltip-"+id+"' class='tooltip-popup' onclick=\"pemco.tooltip.hide('"+id+"');\">"
                                 +     "<div class='tooltip-top'><div class='tooltip-top-icon'></div></div>"
                                 +     "<div class='tooltip-middle'>"
                                 +          tipText
                                 +     "</div>"
                                 +     "<div class='tooltip-bottom'></div>"
                                 + "</div>");
        
    }

    pub.toggle = function(id)
    {
        if(tipExpanded[id])
        {
            pub.hide(id);
        }
        else
        {
            pub.show(id);
        }
    }

    pub.show = function(id) {
        if(!tipExpanded[id])
        {
            $("#tooltip-" + id).slideDown(transSpeed);
            tipExpanded[id] = true;
        }
    }

    pub.hide = function(id) {
        if(tipExpanded[id] == true)
        {
            $("#tooltip-" + id).slideUp(transSpeed);
            tipExpanded[id] = false;
        }
    }
    
/*
    <div id="unique-tip-container-id"></div>
    <script language="javascript">pemco.tooltip.create('tip-id', '#unique-tip-container-id', "Put the tip text here.");</script>

 */

})(jQuery);


