
    var JS_supported = (document.getElementById || document.all);

    function getObj(name)
    {
        if (document.getElementById)
        {
            this.obj = document.getElementById(name);
            if (!this.obj)
            {
                this.obj = new Object();
                this.obj.exists = false;
            }
            else
            {
                this.obj.exists = true;
                this.style = document.getElementById(name).style;
            }
        }
        else if (document.all)
        {
            this.obj = document.all[name];
            if (!this.obj)
            {
                this.obj = new Object();
                this.obj.exists = false;
            }
            else
            {
                this.obj.exists = true;
                this.style = document.all[name].style;
            }
        }
        else if (document.layers)
        {
            this.obj = document.layers[name];
            if (!this.obj)
            {
                this.obj = new Object();
                this.obj.exists = false;
            }
            else
            {
                this.obj.exists = true;
                this.style = document.layers[name];
            }
        }
    }

    function getTags(name)
    {
        if (!JS_supported)
            return 0;

        if (document.getElementById)
            return document.getElementsByTagName(name);
        else
            return document.all.tags(name);
    }

    function trim(s)
    {
        while (s.substring(0, 1) == ' ')
            s = s.substring(1, s.length);

        while (s.substring(s.length - 1, s.length) == ' ')
            s = s.substring(0, s.length - 1);

        return s;
    }

    function deletedoc(docid, doctype)
    {
        if (!confirm('UWAGA! Dokument zostanie stracony bezpowrotnie!\r\nCzy na pewno chcesz go usun±æ?'))
            return false;

        new getObj('docid').obj.value = docid;
        new getObj('doctype').obj.value = doctype;
        deleteform.submit();

        return false;
    }

    function WindowOnload(new_onload_function)
    {
        var prev_onload = window.onload;

        window.onload = function()
                        {
                            if (prev_onload)
                                prev_onload();
                            new_onload_function();
                        };
    }

    function clickImgToggleAction(e)
    {
        if (!JS_supported) return;

        if (!e) var e = window.event;
        if (e.target) var tg = e.target;
        else if (e.srcElement) var tg = e.srcElement;

        var x = tg.id.substring(7);

        tg = new getObj('imglist' + x);
        tglist = new getObj('hidlist' + x);

        if (tglist.style.display == 'none')
        {
            tglist.style.display = 'block';
            tg.obj.src = 'img/up.gif';
            if (x == '_filtry')
            {
                new getObj('action').obj.value = 'full';
            }

            if (x == '_stats' || x == '_filtry')
            {
                x = (x == '_stats') ? '_filtry' : '_stats';
                tg = new getObj('imglist' + x);
                tglist = new getObj('hidlist' + x);

                if (tglist.obj.exists && tglist.style.display == 'block')
                {
                    tglist.style.display = 'none';
                    tg.obj.src = 'img/down.gif';
                }
            }
        }
        else
        {
            tglist.style.display = 'none';
            tg.obj.src = 'img/down.gif';
            if (x == '_filtry')
            {
                new getObj('action').obj.value = 'simple';
            }
        }
    }

    function setCookie(name,value)
    {
        document.cookie = name+"="+value+"; path=/";
    }

    function getCookie(name)
    {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++)
        {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return "";
    }

    function eraseCookie(name)
    {
        var date = new Date();
        date.setTime(date.getTime() - 1000);
        document.cookie = name+ "=; expires=" + date.toGMTString()+ "; path=/";
    }

    function list_wdw_click(e)
    {
        if (!JS_supported) return;

        tg = new getObj('wdw_link').obj;

        divstats = new getObj('hidlist_stats');

        if (tg.href.substring(tg.href.length - 13, tg.href.length - 2) == 'printstats=')
           tg.href = tg.href.substring(0, tg.href.length - 13);
        if (divstats.style.display == 'block')
            tg.href = tg.href + 'printstats=1&';
    }

