function AjaxUpdate(url,containerId)
{
	if(containerId!='')
		url=url+(url.indexOf('?')>0?'&':'?')+'AjaxUpdate='+containerId;	

	$('#'+containerId+' .RollPager').append('<img src="http://nowalama.pl/layout/ajaxwait.gif">');

	$.get(url,null,function(data){
		$('elements > element',data).each(function(){
			el = $('#'+$('id',this).text());
			el.html($('content',this).text());
			$('.RollPager a', el).bind('click',function(){
				return AjaxUpdate(this.href.substring(0,this.href.indexOf('#')), this.href.substring(this.href.indexOf('#')+1));
			});
			$.scrollTo('#'+containerId, 750)
		});
	});

	return false;
}

function AjaxForm_Post(el)
{	
	var array = new Array();
	// zebranie danych z formularza		
	$(el.form).find('input,select,textarea').each(function(){
		var obj = new Object();
		obj.name = this.name;
		obj.value = this.name == '_ajax' ? 'true' : this.value;
		array.push(obj);
	});
			
	return !$.post(
		window.location.href, 
		array,
		function(data) 
		{
			var json = eval("(" + data + ")");
			if (json.error > 0)
			{
				if (json.error == 1)
					alert(json.description);
				if (json.error == 2)
					$('#TB_ajaxContent').load(json.description.replace(/&amp;/g,'&'),null,window[json.initFunction]);
			}
			else
				window.location.reload();
		}
	);
}