
var overTip =
{
    getMousePosition: function(e) {
        var posX = 0;
        var posY = 0;
        if (!e) var e = window.event;
        if (e.pageX || e.pageY) {
            posX = e.pageX;
            posY = e.pageY;
        }
        else if (e.clientX || e.clientY) {
            posX = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
            posY = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
        }
        return { x: posX, y: posY };
    }
	,
    exist: function(id) {
        return ($("#" + id).length > 0);
    }
	,
    showBegin: function(e, id) {
        overTip.hideAll();

        var position = overTip.getMousePosition(e);

        if (!overTip.exist(id)) {
            $(document.body).append("<div id=\"" + id + "\" class=\"overTip\" style=\"display:none;\"><img src=\"/invest/site_images/loading.gif\" class=\"loading\" /></div>");
        }


        $("#main").one("click", overTip.hideAll);

        $("#" + id).css("left", position.x + "px").css("top", position.y + "px").fadeIn("fast");

        if (e.stopPropagation) {
            e.stopPropagation();
        }
        else {
            e.cancelBubble = true
        }

    }
	,
    showEnd: function(id, content) {
        $("#" + id).empty().append($("div.value", content));
    }
	,
    show: function(e, id, content, width, persist, leftOriented) {
        var position = overTip.getMousePosition(e);

        if (!overTip.exist(id)) {
            $(document.body).append("<div id=\"" + id + "\" class=\"overTip\" style=\"display:none;\"></div>");
            $("#" + id).html(content);
        }
        else {
            if (!persist) {
                $("#" + id).html(content);
            }
        }
        var tip = $("#" + id);

        if (leftOriented) {
            tip.css("left", position.x - 150 + "px");
        }
        else {
            tip.css("left", position.x + "px");
        }

        tip.css("top", (position.y + 20) + "px");

        if (width) {
            tip.width(width);
        }

        if (tip.is(":hidden")) {
            overTip.hideAll();
            tip.fadeIn("fast");
        }

        $("#main").one("click", overTip.hideAll);

        if (e.stopPropagation) {
            e.stopPropagation();
        }
        else {
            e.cancelBubble = true
        }
    },
    showEx: function(e, id, content, width, persist, leftOriented, filter) {
        if ($(e.target).is("a.filterClosed")) {
            this.show(e, id, content.replace("{0}", $(e.target).attr("filtername")), width, persist, leftOriented);
        }
    }
	,
    hideAll: function() {
        $("div.overTip").hide();
    }
};
