function show_comments(entry_id) {
  var div_id = '#comment_' + entry_id;
  $(div_id).html('<div style="padding:6px 6px 0 6px;background-color:#dbdbdb"><img src="/images/waiting.gif" alt="loading" width="16" /></div>');
  $.ajax({
    url: '/ajax/get_comments.php?entry_id=' + entry_id,
    success: function (data) { $(div_id).html(data); }
  });
}

function submit_comment(entry_id) {
  var textarea_id = '#comment_content_' + entry_id;
  var notify_div_id = '#comment_notify_' + entry_id;
  var content = $.trim($(textarea_id).val());
  if (content.length < 10) {
    $(notify_div_id).text('Comment is too short.');
    $(textarea_id).focus();
    return false;
  }
  $.ajax({
    type: 'POST',
    data: { 'entry_id':entry_id, 'content':content },
    url: '/ajax/submit_comments.php',
    success: function (data) { $('#notification').html(data); }
  });
}

function show_comment_form(entry_id) {
  var fake_div_id = '#comment_form_fake_' + entry_id;
  var form_div_id = '#comment_form_' + entry_id;
  $(fake_div_id).hide();
  $(form_div_id).show();
}

function hide_comment_form(entry_id) {
  var fake_div_id = '#comment_form_fake_' + entry_id;
  var form_div_id = '#comment_form_' + entry_id;
  $(form_div_id).hide();
  $(fake_div_id).show();
}

function clear_comment_form(entry_id) {
  var textarea_id = '#comment_content_' + entry_id;
  $(textarea_id).val('');
}

function insert_single_comment(entry_id, comment) {
  var comment_div_id = '#comment_' + entry_id;
  $(comment_div_id).append(comment);
}

