function beforeCommentFormSubmit(formData, jqForm, options){
    $('#comment_message').text('Proszę czekać. Trwa wczytywanie danych...');
}

function set_current_comment(id){
    $('#current_comment').val(id);
    get_object_comments();
}

function get_object_comments(){
    $('#object_comments_form').submit();
    $.ajax({
       type: "POST",
       url: "/comments/object_comments/",
       data: "object_pk=" + $('#id_object_pk').val() + "&content_type=" + $('#id_content_type').val() + "&only_current=True&current_comment=" + $('#current_comment').val() ,
       success: function(msg){                    
          $('#current_comment_containter').html(msg);
       }
    });
}

function showCommentFormResponse(responseText, statusText){
    $('#comment_message').text('');
    if (responseText != 'ok'){
        $('#comment').html(responseText);
    } else {
        $('#id_name').val('');
        $('#id_comment').val('');
        $('#comment').attr('class','no-display');
    }
    get_object_comments();
}

function send_comment_form(){
    $('#comment_form').submit(function() {
        $(this).ajaxSubmit({type: 'post',
                            beforeSubmit: beforeCommentFormSubmit, 
                            success: showCommentFormResponse});
        return false; 
    });
}