function on_publish_comment(form_id) {
  // Require connect to publish a comment.
  FB.Connect.requireSession(function() {
    // prompt for publish permissions if they don't exist. Once the dialog
    // closes, continue on with submit request.
    FB.Connect.showPermissionDialog('publish_stream', function() {
      $(form_id).submit();
    });
  });
  return false;
}

function toggle_reply(comment_div_id, reply_div_id) {
  $(reply_div_id).hide();
  $(comment_div_id).show();
  $(comment_div_id + ' form:first textarea').focus();
}

function show_friend_comments() {
  $('#everyone_comments_wrapper').hide();
  $('#everyone_tab').removeClass('current');
  $('#friends_tab').addClass('current');
  $('#friends_comments').show();
}

function show_all_comments() {
  $('#friends_comments').hide();
  $('#friends_tab').removeClass('current');
  $('#everyone_tab').addClass('current');
  $('#everyone_comments_wrapper').show();
}

function more_comments(post_id, div_name) {
  div_id = "#" + div_name
  progress_id = div_id + "_progress_bar";
  more_comments_id = div_id + "_more";
  div_name_for_post = div_name + "_" + post_id;
  div_wrapper = div_id + "_wrapper";

  $(more_comments_id).remove();
  $(progress_id).show();
  $.get(MORE_COMMENTS_URL, { 'last_comment' : post_id }, function(data) {
    $(progress_id).remove();
    // Wrap the comments in a div so facebook can selectively reparse it
    // with the parseDomElement call.
    $(div_wrapper).append(data);
    FB.XFBML.Host.parseDomElement($("#" + div_name_for_post).get(0));
  });
}
