﻿var GlobalTimer;
var GlobalId="";
var alpha=0;

function ShowBalloon(divId)
{
    window.clearTimeout(GlobalTimer);
    
    if (divId!=GlobalId)
    {
        HideLayer();
        GlobalId=divId;
        document.getElementById(GlobalId).style.display='block';
        document.getElementById(GlobalId).style.filter="alpha(opacity=0)";
        document.getElementById(GlobalId).style.MozOpacity=0;
        document.getElementById(GlobalId).style.opacity=0;
        alpha=0;
        RevealLayer();
    }
}

function WriteBalloonContent(divId, width, height, theme, title, body)
{
        if(document.frames)
            {
            if (height==-1)
                height=100;
            if (width==-1)
                width=245


            document.frames[divId].document.write("<html><head><link href='" + theme + "' rel='stylesheet'></head><body topmargin='0' leftmargin='0' bottommargin='0' rightmargin='0' style='background:transparent'><div class='BalloonTop' style='" + (width==-1 ? "" : "width:" + width + "px;") + "'>" + title + "</div><div class='BalloonBody' style='" + (height==-1 ? "" : "height:" + height + "px;") + "'>" + body + "</div><div class='BalloonBottom' style='" + (width==-1 ? "" : "width:" + width + "px;") + "'></div></body></html>");
                
            document.getElementById(divId).height=height+ 19;
            
            document.getElementById(divId).width=width;
            }
        else
        {
            if (height==-1)
                height=100;
            if (width==-1)
                width=245

            document.getElementById(divId).contentDocument.write("<html><head><link href='" + theme + "' rel='stylesheet'></head><body topmargin='0' leftmargin='0' bottommargin='0' rightmargin='0' style='background:transparent'><div class='BalloonTop' style='" + (width==-1 ? "" : "width:" + width + "px;") + "'>" + title + "</div><div class='BalloonBody' style='" + (height==-1 ? "" : "height:" + height + "px;") + "'>" + body + "</div><div class='BalloonBottom' style='" + (width==-1 ? "" : "width:" + width + "px;") + "'></div></body></html>");
            document.getElementById(divId).height=height+ 30;
            document.getElementById(divId).width=width;

        }
}

function RevealLayer()
{
    document.getElementById(GlobalId).style.filter="alpha(opacity=" + alpha*10 + ")";
    document.getElementById(GlobalId).style.MozOpacity=alpha/10;
    document.getElementById(GlobalId).style.opacity=alpha/10;
    alpha++;
    if (alpha<=10)
    {
        setTimeout(RevealLayer, 10);
    }
}

function HideBalloon()
{
    GlobalTimer = setTimeout(HideLayer, 1000);
}

function HideLayer()
{
    if(GlobalId!="")
    {
        document.getElementById(GlobalId).style.display='none';
        GlobalId="";
    }
}
