function ajax(url, data, target, readyfunction)
{
	$.ajax({
		type: "POST",
		url: url,
		data: data,
		complete: function(xhr) {
		    if(typeof target == 'undefined' && xhr.responseText != '')
            {
                alert(xhr.responseText);
            }
            else if(typeof target != 'undefined')
            {
                $( target ).html( xhr.responseText );
                if(typeof readyfunction != 'undefined')
                {
                    eval(readyfunction + '()');
                }
            }
		}
	});
}

function referenciak(p)
{
    $('#lablec_referenciak').html( '<img class="ajax_loader" src="images/ajax_loader.gif" />');
    ajax('_lablec_referenciak.php', 'page=' + p, '#lablec_referenciak', 'thickboxInit');
}

function thickboxInit()
{
    tb_init('a.thickbox, area.thickbox, input.thickbox');
    imgLoader = new Image();
    imgLoader.src = tb_pathToImage;
}