$(document).ready(function() {
    $('#blastCommentButton').toggle(function() {
        $('#blastCommentBlock').fadeIn();
    }, function() {
        $('#blastCommentBlock').fadeOut();
    });

    var options = {
        beforeSubmit:  showRequest,  // pre-submit callback
        success:      showResponse  // post-submit callback
    };

    $('#commentForm').ajaxForm(options);

    $('#changeBlast').toggle(function() {
        $('.message').hide();
        $('#new-blast').show();
    }, function() {
       $('.message').show();
        $('#new-blast').hide();
    });


    $("#content-message").counter({
        count: 'down',
        goal: 250
    });

    $('#blastingForm').validate();

});

function showRequest(formData, jqForm, options) {
    var queryString = $.param(formData);
    $('#comment-loader').html('<img src="images/ajax-loader.gif" />');
    return true;
}

function showResponse(responseText, statusText)  {
    $('#comment-loader').html(' ');
    $('#comment-content').val('');
    $('#comment-new').replaceWith(responseText);
}

function commentDelete(commentid) {
    $.ajax({
        type: "GET",
        url: "blasting.php",
        data: "do=deletecomment&commentid="+commentid,
        success: function(msg) {
            if (msg == 1)
                $('#comment-'+commentid).fadeOut();
        }
    });
}
