gremmie@1: $(document).ready(function() {
gremmie@1:     $('#comment-form-post').click(function () {
gremmie@1:         $(this).attr('disabled', 'disabled').val('Posting Comment...');
gremmie@1:         $.post('/comments/post/', { 
gremmie@1:             comment : $('#id_comment').val(), 
gremmie@1:             content_type : $('#id_content_type').val(), 
gremmie@1:             object_pk : $('#id_object_pk').val() 
gremmie@1:             }, 
gremmie@1:             function (data, textStatus) {
gremmie@1:                 $('#id_comment').val(''); 
gremmie@1:                 $('#comment-list').append(data);
gremmie@1:                 var lastLi = $('#comment-list > li:last');
gremmie@1:                 lastLi.hide();
gremmie@1:                 lastLi.fadeIn(3000);
gremmie@1:                 $('#comment-form-post').removeAttr('disabled').val('Post Comment');
gremmie@1:                 var count = $('#comment-count');
gremmie@1:                 if (count.length) {
gremmie@1:                     count.html(parseInt(count.html()) + 1);
gremmie@1:                 }
gremmie@1:             }, 
gremmie@1:             'html');
gremmie@1:         return false;
gremmie@1:     });
gremmie@1:     $('a.comment-flag').click(function () {
gremmie@1:         var id = this.id;
gremmie@1:         if (id.match(/fc-(\d+)/)) {
gremmie@1:             id = RegExp.$1;
gremmie@1:             if (confirm('Only flag a comment if you feel it is spam, abuse, violates site rules, ' +
gremmie@1:                     'or is not appropriate. ' +
gremmie@1:                     'A moderator will be notified and will review the comment. ' +
gremmie@1:                     'Are you sure you want to flag this comment?')) {
bgneal@99:                 $.ajax({
bgneal@99:                   url: '/comments/flag/',
bgneal@99:                   type: 'POST',
bgneal@99:                   data: {id: id}, 
bgneal@99:                   dataType: 'text',
bgneal@99:                   success: function (response, textStatus) {
bgneal@99:                      alert(response);
bgneal@99:                   },
bgneal@99:                   error: function (xhr, textStatus, ex) {
bgneal@99:                      alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
bgneal@99:                   }
bgneal@99:                 });
gremmie@1:             }
gremmie@1:         }
gremmie@1:         return false;
gremmie@1:     });
gremmie@1:     $('#id_comment').markItUp(mySettings);
gremmie@1: });