function closeCurrentTooltip (event) {
    //Find the parent of the tooltip (with id=tooltip).
    var closeBtn = $(event.target);
    var tltip = closeBtn.closest("#tooltip");
    tltip.html("");
    tltip.css ("display", "none");
}

function closeTooltips () {
    $("#tooltip_container").each (function () {
        $(this).remove ();
    });
    
    $("#tooltip").each (function () {
        $(this).html ("");
        $(this).css ("display", "none");
    });
}

function getPosition (obj) {
    var curleft = curtop = 0;
    try {
        if (obj.offsetParent && typeof(obj.offsetParent) == "object") {
            do {
                curleft += obj.offsetLeft;
                curtop += obj.offsetTop;
            } while ((obj = obj.offsetParent))
        }
        
        //Try jquery.
        curleft = obj.offset().left;
        curtop = obj.offset().top;
    } catch (e) { }

    return {
        "left": curleft, 
        "top": curtop
    };        
}

function getDimension (obj) {
    var width = height = 0;
    try {
        if (obj.offsetWidth) {
            width = obj.offsetWidth;
            height = obj.offsetHeight;
        }
        
        //Try jquery.
        width = obj.width();
        height = obj.height();
    } catch (e) { }

    return {
        "width": width, 
        "height": height
    };
}

