function ajax_lista_napelnij( _source, _list, _select, _callback )
{
    $.ajax(
    {
	url: _source,
	type: 'GET',
	dataType: 'xml',
	success: function( xml )
	{
	    form_lista_reset( _list );

	    $(xml).find('nazwa').each( function()
	    {
		$('<option></option>')
		    .html( $(this).text() )
		    .attr( 'value', $(this).attr('id') )
		    .appendTo( _list );
	    } );
	    
	    $.browser.msie ? setTimeout(zaznacz,1) : zaznacz();

	    if( _callback )
		_callback( );

	    function zaznacz()
	    {
	        $( _list ).attr( 'value', _select );
	    }
	}
    } );
}

function form_lista_reset_new( _target )
{
    $( _target ).each( function()
    {
	if( $('<option></option>').val > 0 )
    	    $( this ).find( 'option' ).remove( );
    } );
    
}

function form_lista_reset( _target )
{
    $( _target ).each( function()
    {
	$( this ).find( 'option' ).remove( );
	$( '<option></option>' )
	    .html( '-- wybierz --' )
	    .val( 0 )
	    .appendTo( $(this) );
    } );
}

var ajax_wypelnij_dane = {};
function ajax_wypelnij( _target, _function, _presentation_id, _options )
{
    if(ajax_wypelnij_dane[_target]==_function)
	return;

    ajax_wypelnij_dane[_target] = _function;

    $( _target ).html( '<div style=\"text-align: center;\"><img src=\"/img/grafiki/loadingAnimation.gif\" alt=\"\" /></div>' );

    __post = 'akcja=' + _function + (_presentation_id ? '&id_prezentacji='+_presentation_id : '');

    if(_options)
    {
	__n = _options.length;
	while(__n--)
	    __post += '&' + _options[__n].name + '=' + _options[__n].value;
    }

    $.ajax({
	type: 'POST',
	url: '/source/ajax/obszary.php',
	data: __post,
	success: function( _html ){
	    $( _target ).html( _html );
	}
    });
}