function showRequest(formData, jqForm, options) {
	$('#addCommentResult').html('<strong>Trwa przetwarzanie danych</strong> <img src="/szablon/02/mod/comments/img/ajax-loader2.gif">');	 
    return true; 
} 
  
function showResponse(responseText, statusText)  {      
    $('#commentsContent').html(responseText);             
}

function proccedJson(data) {	
	//$('.addComment').html('');	
	$('#addCommentResult').html(data.komunikat);	
	if ( data.pola ) {	
		for ( i = 0; i < data.pola.length; i++ ) {		
			$('#' + data.pola[i]).css('border', '2px solid red');
		}
	}
	odswiezCaptcha(data.sciezka);			
}
 
function pokazListe(warstwa, img, adres) {
	$('#commentsContent').hide();	
	$('#commentsTabList').attr('class', '');
	$('#commentsTabAdd').attr('class', 'off');		
	$('#' + warstwa).toggle();
	
	pobierzKomentarze(adres);	
}  
 
function pokazFormularz(warstwa, img) {	
	$('#showComments').hide();	
	$('#commentsTabList').attr('class', 'off');
	$('#commentsTabAdd').attr('class', '');	
	$('#' + warstwa).toggle();	
} 

/* 
$(document).ready(function() { 
	$('#showComments').hide();
	var options = {          
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       proccedJson,  // post-submit callback 
 
         
        dataType:  'json'       // 'xml', 'script', or 'json' (expected server response type)          
    };
		
    // bind 'myForm' and provide a simple callback function 
    $('#dodajKomentarz').ajaxForm(options); 
});
*/

function odswiezCaptcha(sciezka) {
 	$.post(sciezka + 'index.php?modul=PubECmsKomentarz&akcja=odswiezCaptcha', function(response){
 		$('.captcha').html(response);
 	});
}

function pobierzKomentarze(adres) {
	
	$("#loading").ajaxStart(function(){
   		$(this).html('<strong>Trwa wczytywanie listy</strong> <img src="/szablon/02/mod/comments/img/ajax-loader2.gif">');
 	});
	

	$.post(adres, function(response){
 		$('#showComments').html(response);
 	});
}


