function ajaxAddComment(guid)
{	
	var comment = $F('f_text');
	if(comment != '')
	{
		comment = comment.replace(/\n/g, "<br />");
		new Ajax.Request(siteurl + '/profil/' + guid + '/ajax',
		  	{
				asynchronous: true,
		   		method: 'post',
		   		postBody: 
		   			"comment=" + encodeURIComponent(comment),
		   		onComplete: function(obj) { ajaxAddCommentComplete(obj.responseText); }	   		
		   	});	
   	}
   	else
   	{
		showAlert('Nowy komentarz', 'Musisz wpisać treść komentarza!');
	}
	return false;
}

function ajaxUserAddComment(guid)
{	
	var comment = $F('f_text');
	if(comment != '')
	{
		comment = comment.replace(/\n/g, "<br />");
		new Ajax.Request(siteurl + '/konto/ajaxBook',
		  	{
				asynchronous: true,
		   		method: 'post',
		   		postBody: 
		   			"comment=" + encodeURIComponent(comment),
		   		onComplete: function(obj) { ajaxAddCommentComplete(obj.responseText); }	   		
		   	});	
   	}
   	else
   	{
		showAlert('Nowy komentarz', 'Musisz wpisać treść komentarza!');
	}
	return false;
}


function ajaxAddCommentComplete(output)
{
	if(output.indexOf('ERROR') != -1)
	{		
		showAlert('Nowy komentarz', 'Wystąpił nieoczekiwany błąd. Przepraszamy i prosimy spróbować później.' + output);
		return;
	} 
	else
	{	
		var e = $('profilBook');
		e.innerHTML = output + e.innerHTML;
		$('f_text').value = '';
	}
}
