var step        = 5
var stepTime    = 5;
var stepCount   = null;
var timeId      = null;
var id          = 0;

function animujOkno(INwindowId, INstart, INstop, INkrok, INafterAll)
{
    var okno=document.getElementById(INwindowId);

    if( (INkrok>0 && stepCount <= INstop) || (INkrok<0 && stepCount >= INstop) )
    {
        okno.style.opacity = (stepCount/100); // wszystko
        okno.style.filter = 'alpha(opacity='+(stepCount)+')'; // IE
        stepCount += INkrok;

    }else
    {
        okno.style.opacity = (INstop/100);
        okno.style.filter = 'alpha(opacity='+INstop+')';

        if( INstop==0  )
            okno.style.visibility='hidden';

        stepCount = INstart;
        clearInterval(timeId);

        if(INafterAll.length>1 )
            eval(INafterAll);
    }
}

function pokazOkno(INwindowId)
{
    stepCount = 0;
    var okno=document.getElementById(INwindowId);
    okno.style.opacity = 0; // wszystko
    okno.style.filter = 'alpha(opacity=0)'; // IE
    okno.style.visibility='visible';
    
    timeId = setInterval('animujOkno("'+INwindowId+'",0,100,'+step+',"")',stepTime);
    setTimeout('ukryjOkno("'+INwindowId+'")', 5000);
}

function ukryjOkno(INwindowId)
{
    stepCount = 100;
    timeId = setInterval('animujOkno("'+INwindowId+'",100,0,-'+step+',"referencja()")',stepTime);
}

//pokazOkno('textContainer');
//ukryjOkno('textContainer');

function referencja()
{
     if( xmlHttp.readyState==4 ||xmlHttp.readyState==0 )
     {
        xmlHttp.open("GET","pokazReferencje.php?id="+id,true);
        xmlHttp.onreadystatechange = referencjaShow;
        xmlHttp.send(null);
     }
     else
     {
        setTimeout('referencja()', 100);
     }
}



function referencjaShow()
{
    var tresc = '';
    var podpis = '';

    if( xmlHttp.readyState==4 )
    {
        if( xmlHttp.status == 200 )
        {
            xmlResponse         = xmlHttp.responseXML;
            xmlDocumentElement  = xmlResponse.documentElement;

            tresc   = xmlDocumentElement.getElementsByTagName("tresc").item(0).firstChild.data;
            id      = xmlDocumentElement.getElementsByTagName("id").item(0).firstChild.data;
            podpis  = xmlDocumentElement.getElementsByTagName("podpis").item(0).firstChild.data;

            var container= document.getElementById('textContainer');

            container.innerHTML = tresc

            if( podpis.length>1 )
                container.innerHTML += '<p style="font-weight:bold;text-align:right">'+podpis+'</p>';

            pokazOkno('textContainer');

        }else
            alert("Wystąpił błąd podczas dostępu do serwera "+xmlHttp.statusText);
    }
}

