var arrElement = new Array();
var blnAjaxDebug = false;

function $( id )
{
        return document.getElementById( id );
}

function SelectAll()
{
        var now = $( 'selchck' ).checked;
        var form = $( 'list' );
        var elements = form.elements;
        if( now == true )
        {
                for( i=1; i<=form.length; i++ )
                {
                        elements[i].checked = 'checked';
                }
        }
        else
        {
                for( i=1; i<=form.length; i++ )
                {
                        elements[i].checked = '';
                }
        }
}

function showSubSector ( sectorId )
{
        link = "__ajax.php?act=show_sub_sector&id="+sectorId;
        
        advAJAX.get (
        {
                url: link,
                onLoading : function()
                {
                        document.getElementById( 'show_'+sectorId ).innerHTML = 'wczytywanie... &nbsp; <img src="img/loader.gif" style="position: relative;" />';
                },
                onSuccess : function(obj)
                {
                        document.getElementById( 'sec_'+sectorId ).innerHTML = obj.responseText;
                        document.getElementById( 'show_'+sectorId ).innerHTML = '';
                        ajaxDebug( obj.responseText );
                },
                onError : function(obj)
                {
                        window.alert('Wystąpił nieoczekiwany błąd.\nProszę powtórzyć operację lub\nskontaktować się z administratorem.');
                }
       }
       );
}

function hide ( id )
{
        eval("document.getElementById('"+id+"').style.display='none'");
}

function show ( id )
{
        eval("document.getElementById('"+id+"').style.display=''");
}

function addCompany ( id )
{
        link = "__ajax.php?act=add_company&id="+id;
        
        advAJAX.get (
        {
                url: link,
                onLoading : function()
                {
                        document.getElementById( 'status_'+id ).innerHTML = '<img src="img/loader.gif" />';
                },
                onSuccess : function(obj)
                {
                        document.getElementById( 'status_'+id ).innerHTML = '<img src="img/ok.gif" border="0" />';
                        document.getElementById( 'add_'+id ).style.display = 'none';
                        ajaxDebug( obj.responseText );
                },
                onError : function(obj)
                {
                        window.alert('Wystąpił nieoczekiwany błąd.\nProszę powtórzyć operację lub\nskontaktować się z administratorem.');
                }
       }
       );
}
function checkPacket ( id )
{
        var pack = document.packet.pa.value;

        link = "__ajax.php?act=check_packet&pack="+pack+"&id="+id;
        
        advAJAX.get (
        {
                url: link,
                onLoading : function()
                {
                        document.getElementById( 'ok' ).innerHTML = ' &nbsp; <img src="img/loader.gif" style="display: inline; margin-bottom: -3px;" />';
                },
                onSuccess : function(obj)
                {
                        document.getElementById( 'ok' ).innerHTML = ' &nbsp; <img src="img/ok.gif" border="0" style="display: inline; margin-bottom: -3px;" />';
                        ajaxDebug( obj.responseText );
                },
                onError : function(obj)
                {
                        window.alert('Wystąpił nieoczekiwany błąd.\nProszę powtórzyć operację lub\nskontaktować się z administratorem.');
                }
       }
       );
}

function getNews ( id )
{
        link = "__ajax.php?act=get_news&id="+id;
        
        advAJAX.get (
        {
                url: link,
                onLoading : function()
                {
                        document.getElementById( 'all_news' ).innerHTML = '<br /><br /><center><img src="img/loader.gif" style="position: relative;" /></center>';
                },
                onSuccess : function(obj)
                {
                        document.getElementById( 'all_news' ).innerHTML = obj.responseText;
                        ajaxDebug( obj.responseText );
                },
                onError : function(obj)
                {
                        window.alert('Wystąpił nieoczekiwany błąd.\nProszę powtórzyć operację lub\nskontaktować się z administratorem.');
                }
       }
       );
}
