    function getXMLHttpRequest()
    {
        var request = false;
    
        try {
            request = new XMLHttpRequest();
        } 
        catch(err1) {
            try {
                request = new ActiveXObject('Msxml2.XMLHTTP');
            } 
            catch(err2) {
                try {
                    request = new ActiveXObject('Microsoft.XMLHTTP');
                } 
                catch(err3) {
                    try {
                        request = new ActiveXObject('MSXML2.XMLHttp.5.0');
                    }
                    catch(err4) {
                        try {
                            request = new ActiveXObject('MSXML2.XMLHttp.4.0');
                        }
                        catch(err5) {
                            try {
                                request = new ActiveXObject('MSXML2.XMLHttp.3.0');
                            }
                            catch(err6) {
                                request = false;
                            }
                        }
                    }
                }
            }
        }
        return request;
    }
    
    var r;
    r = getXMLHttpRequest();    
    
    var element;
    
    function processResponse()
    {
        if (r.readyState == 4) {
            if (r.status == 200) {
                    
                FilePath = './pa/';
                adres = 'pomoc.php?id=';
                
                if ( $('admin') ) {
                    adres = 'index.php?d=kategorie_pomoc_spis&a=pytania&id=';
                    FilePath = './';
                }
    
                var x_records = r.responseXML.getElementsByTagName('records')[0].childNodes;
                var tmp = '';
                var znacznik = 1;

                for ( j=0; j<x_records.length; j++ ) {

                    var x = r.responseXML.getElementsByTagName('record')[j].childNodes;
                    for (i = 2; i < x.length; i++) {
                        if ( r.responseXML.getElementsByTagName('record')[j].getAttribute("last") == 1 ) {
                            if ( $('admin') ) {
                                if ( znacznik == x_records.length ) {
                                    tmp = tmp + '<div class="tresc"><h3><img src="'+FilePath+'img/joinbottom.gif"><img src="'+FilePath+'img/page.gif"> <a href="'+adres+x[0].childNodes[0].nodeValue+'&name'+x[i].childNodes[0].nodeValue+'">'+x[i].childNodes[0].nodeValue+'</a></h3><div></div></div>';
                                }
                                else {
                                    tmp = tmp + '<div class="tresc"><h3><img src="'+FilePath+'img/join.gif"><img src="'+FilePath+'img/page.gif"> <a href="'+adres+x[0].childNodes[0].nodeValue+'&name'+x[i].childNodes[0].nodeValue+'">'+x[i].childNodes[0].nodeValue+'</a></h3><div></div></div>';
                                }
                            }
                            else {
                                if ( znacznik == x_records.length ) {
                                    tmp = tmp + '<div class="tresc"><h3><img src="'+FilePath+'img/joinbottom.gif"><img src="'+FilePath+'img/page.gif"> <a href="'+adres+x[0].childNodes[0].nodeValue+'">'+x[i].childNodes[0].nodeValue+'</a></h3><div></div></div>';
                                }
                                else {
                                    tmp = tmp + '<div class="tresc"><h3><img src="'+FilePath+'img/join.gif"><img src="'+FilePath+'img/page.gif"> <a href="'+adres+x[0].childNodes[0].nodeValue+'">'+x[i].childNodes[0].nodeValue+'</a></h3><div></div></div>';
                                }
                            }
                            
                        }
                        else {
                             if ( $('admin') ) {
                                  tmp = tmp + '<div class="tresc"><h3><a id="'+x[0].childNodes[0].nodeValue+'" href="#1" name="'+x[i].childNodes[0].nodeValue+'" onclick="expandCollapse_1(this,'+x[0].childNodes[0].nodeValue+','+x[0].childNodes[0].nodeValue+');"><img src="'+FilePath+'img/nolines_plus.gif"><img src="'+FilePath+'img/folder.gif"></a><a href="'+adres+x[0].childNodes[0].nodeValue+'&lock=tak"> ' +x[i].childNodes[0].nodeValue+'</a></h3><div></div></div>';
                             }
                             else {
                                  tmp = tmp + '<div class="tresc"><h3><a id="'+x[0].childNodes[0].nodeValue+'" href="#1" name="'+x[i].childNodes[0].nodeValue+'" onclick="expandCollapse_1(this,'+x[0].childNodes[0].nodeValue+','+x[0].childNodes[0].nodeValue+');"><img src="'+FilePath+'img/nolines_plus.gif"><img src="'+FilePath+'img/folder.gif"> ' +x[i].childNodes[0].nodeValue+'</a></h3><div></div></div>';
                             }
                        }
                        znacznik++;
                    }
                }
                element.innerHTML = tmp;
            };
        }
    }


    function expandCollapse_1(Id, Numer, nr)
    {
        if ( $('admin') ) {
            FilePath = './';
            nazwa = '';
        }
        else {
            FilePath = './pa/';
            nazwa = ' '+$(nr).name;
        }
        
        element = Id.parentNode.parentNode.childNodes[1];
        if (element.style.display == 'block') {
            element.style.display = 'none';        
            Id.innerHTML = '<img src="'+FilePath+'img/nolines_plus.gif"><img src="'+FilePath+'img/folder.gif">'+nazwa;
        }
        else {
            element.style.display = 'block';
            Id.innerHTML = '<img src="'+FilePath+'img/nolines_minus.gif"><img src="'+FilePath+'img/folderopen.gif"><b>'+nazwa+'</b>';
            r.open('GET', FilePath+'xml/pomoc_xml.php?dostep=tak&a=' + Numer, true);
            r.onreadystatechange = processResponse;
            r.send(null);
        }
    }
    
    function expandCollapse_close(numer)
    {
        if (document.getElementById('admin')) {
            FilePath = './';
        }
        else {
            FilePath = './pa/';
        }
        
        for(i=0; i<numer; i++) {
            Id = $(-200+i)
            if (Id) {
                if (Id.parentNode) {
                    if (Id.parentNode.parentNode) {
                        if (Id.parentNode.parentNode.childNodes[1]) {
                            if( $('admin') ) {
                                $(-200+i).parentNode.parentNode.childNodes[1].style.display = 'none';
                                $(-200+i).innerHTML = '<img src="'+FilePath+'img/nolines_plus.gif"><img src="'+FilePath+'img/folder.gif">';
                            }
                            else {
                                $(-200+i).parentNode.parentNode.childNodes[1].style.display = 'none';
                                $(-200+i).innerHTML = '<img src="'+FilePath+'img/nolines_plus.gif"><img src="'+FilePath+'img/folder.gif"> '+document.getElementById(-200+i).name;
                            }
                        }
                    }
                }
            }
        }
    }
    
    function $(wartosc) {
        return document.getElementById(wartosc);
    }

