$(document).ready(function()
{
        $('#addComments').toggle( function() { $('#comHtml').slideDown('slow'); }, function() { $('#comHtml').slideUp('slow'); } );
        /*
        $('#addComments').click(function()
        {
                $('#comHtml').slideDown('slow');
                
                return false;
        });
        
        $('#formAddComments').submit(function()
        {
                var error = 0;
                
                if ( $(this).find('input[name="comAuthor"]').attr('value') == '' )
                {
                        error = 1;
                }
                
                if ( $(this).find('textarea[name="comText"]').attr('value') == '' )
                {
                        error = 1;
                }
                
                if ( error == 0 )
                {
                        document.formAddComments.submit();
                }
                
                return false;
        });
        */
});

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 commUserId ( id )
{
        var userId = document.user.us.value;

        link = "__ajax.php?act=check_user&commId="+id+"&userId="+userId;
        
        advAJAX.get (
        {
                url: link,
                onLoading : function()
                {
                        document.getElementById( 'ok2' ).innerHTML = ' &nbsp; <img src="img/loader.gif" style="display: inline; margin-bottom: -3px;" />';
                },
                onSuccess : function(obj)
                {
                        document.getElementById( 'ok2' ).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.');
                }
       }
       );
}

function checkLink ()
{
        var www = document.add.comLink.value;
        
        link = "__ajax.php?act=check_link&link="+www;
        
        advAJAX.get (
        {
                url: link,
                onLoading : function()
                {
                        document.getElementById( 'ok3' ).innerHTML = ' &nbsp; <img src="img/loader.gif" style="display: inline;" />';
                },
                onSuccess : function(obj)
                {
                       if ( obj.responseText == 1 )
                       {
                                document.getElementById( 'ok3' ).innerHTML = ' &nbsp; <img src="img/ok.gif" border="0" style="display: inline; margin-bottom: -1px;" />';
                       }
                       else
                       {
                                document.getElementById( 'ok3' ).innerHTML = ' &nbsp; <img src="img/no.gif" border="0" style="display: inline; margin-bottom: -1px;" />';
                       }
                },
                onError : function(obj)
                {
                        window.alert('Wystąpił nieoczekiwany błąd.\nProszę powtórzyć operację lub\nskontaktować się z administratorem.');
                }
       }
       );
}

