var mouseEvent;
var oldShowedComment;

if (navigator.appName != "Microsoft Internet Explorer")
    document.onmouseup = function(e)
    {
        mouseEvent = e;
    }

function showComment(commentId)
{
    var comment = document.getElementById(commentId);
    if (oldShowedComment != null)
    {
        oldShowedComment.style.visibility = "hidden";
        oldShowedComment = null;
    }
    oldShowedComment = comment;
    comment.style.left = getPopupLeftPos() + "px";
    comment.style.top = (getPopupTopPos() - 85) + "px";
    comment.style.visibility = "visible";
}

function hideComment(commentId)
{
    var comment = document.getElementById(commentId);
    comment.style.visibility = "hidden";
    oldShowedComment = null;
}


function getPopupTopPos()
{
    if (navigator.appName == "Microsoft Internet Explorer")
    {
        var idx = navigator.userAgent.indexOf("MSIE ");
        if (idx != -1)
        {
            var version = navigator.userAgent.substr(idx + 5, 1);
            if (version * 1 >= 8)
                return window.event.y;
            else
                return window.event.y + getYScroll();
        }
        else return window.event.y;
    } else
    {
        return mouseEvent.pageY;
    }
}

function getYScroll()
{
    return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getXScroll()
{
    return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function getPopupLeftPos()
{
    if (navigator.appName == "Microsoft Internet Explorer")
    {
        var idx = navigator.userAgent.indexOf("MSIE ");
        if (idx != -1)
        {
            var version = navigator.userAgent.substr(idx + 5, 1);
            if (version * 1 >= 8)
                return window.event.x;
            else
                return window.event.x + getXScroll();
        }
        else return window.event.x;
    } else
    {
        return mouseEvent.pageX;
    }
}

