
var g_nIntervalId;
var g_sAnimDiv;
var xTo;
var yTo;


function g_showdlg(parent, div)
{
    var myDrag = $(div).makeDraggable(
    {
        handle :$('dlgbox_title'),
        onComplete: function()
        {
        }
    });

    clearInterval(g_nIntervalId);
    g_sAnimDiv = document.getElementById(div);

    var wndSize = window.getSize();
    var wndScroll = window.getScroll();

    //szerokość i wysokość
    sWidth = g_sAnimDiv.style.width;
    sHeight = g_sAnimDiv.style.height;

    if( sWidth == '' )
            sWidth = '0px';

    if( sHeight == '' )
            sHeight = '0px';

    sWidth = sWidth.substr(0, sWidth.indexOf('px'));
    sHeight = sHeight.substr(0, sHeight.indexOf('px'));

    nWidth = parseInt(sWidth);
    nHeight = parseInt(sHeight);

    xTo = wndSize.x / 2 - nWidth / 2;
    yTo = wndSize.y / 2 - nHeight / 2;

    g_nOpacity = 0;
    g_sAnimDiv.style.opacity = 0;
    g_sAnimDiv.style.filter = 'alpha(opacity=0)';

    g_sAnimDiv.style.left = xTo + 'px';

    nOffset = (document.documentElement.scrollTop || document.body.scrollTop);
    g_sAnimDiv.style.top = yTo + nOffset + 'px';
    g_sAnimDiv.style.display='block';

    g_nIntervalId = window.setInterval("g_animDlg()", 50);
}

function g_closeDlg(div)
{
    clearInterval(g_nIntervalId);
    g_sAnimDiv = document.getElementById(div);
    g_nIntervalId = window.setInterval("g_animDlg2()", 50);
}


var g_nOpacity = 0;
function g_animDlg()
{
    {
        if( g_nOpacity < 1 )
        {
            g_nOpacity = g_nOpacity + 0.2;
            g_sAnimDiv.style.opacity = g_nOpacity;
            g_sAnimDiv.style.filter = 'alpha(opacity='+ (g_nOpacity) * 100 +')';
        }
        else
        {
            clearInterval(g_nIntervalId);
        }
    }
}

function g_animDlg2()
{
    if( g_nOpacity >= 0 )
    {
        g_nOpacity = g_nOpacity - 0.2
        g_sAnimDiv.style.opacity = g_nOpacity;
        g_sAnimDiv.style.filter = 'alpha(opacity='+ (g_nOpacity) * 100 +')';
    }
    else
    {
        clearInterval(g_nIntervalId);
        g_sAnimDiv.style.display='none';
    }
}


