
// funkcja wykonywana gdy przycisniemy przycisk dodaj komentarz
// laduje ajaxem formularz
var showForm = function(id) {
	$(".commentFormDiv").html('<p><strong>Ładuję formularz...</strong></p>').load(baseDir + "comment/index/add/category/1/item_id/" + id, '', function(){
		$('#commentSubmit').click(onSubmitCommentForm);
	});
}
// funkcja ma byc wykonana gdy formularz jest submitowany
var onSubmitCommentForm = function(){
	// blokujemy przycisk i wyswietlamy ifo
	$('#commentSubmit').attr('disabled', 'disabled');
	
	// zbieramy dane z formularza
	var params = {
			category:$("input#category").val()
			,item_id:$("input#item_id").val()
			,name:$("input#name").val()
			,text:$("textarea#text").val()
		};
	
	// wysylamy formularz
    jQuery.post(baseDir + 'comment/index/add', params, submitCommentFormSuccess)
    return false;
}

// submit form callback
var submitCommentFormSuccess = function(r){
	$(".commentFormDiv").html(r)
	$('#commentSubmit').click(onSubmitCommentForm)
}
//
//// ON LOAD
//$(function(){
//	$("#addCommentBtn").click(onClickAddCommentBtn);
//})

