function keydown_reply_comment(evt, comment_id) {
  if (evt.keyCode == 13) {
    $('#comment-'+comment_id+'-reply-post')[0].click()
  }
}

function cancel_reply_comment(comment_id) {
  $('#comment-'+comment_id+'-reply-form').hide();
  $('#comment-'+comment_id+'-reply-icon').fadeIn();
  return false;
}
function reply_comment(comment_id) {
  $('#comment-'+comment_id+'-reply-icon').hide();
  $('#comment-'+comment_id+'-reply-form').fadeIn();
  return false;
}
function post_reply_comment(comment_id) {
  comment_body = $('#comment-'+comment_id+'-reply').val()
  $.post('/comment/reply', { 'body': comment_body, 'comment_id': comment_id }, function() {
    window.location.reload();
  })

}

function post_comment(status_obj_type, status_obj_id, comment_body) {
  comment_body = $('#comment-body').val()
  $.post('/comment/post', { 
    'body': comment_body, 
    'status_object_type': status_obj_type, 
    'status_object_id': status_obj_id}, function() {
      window.location.reload()
    })
}
function update_remaining(input, remaining_id) {
  $('#'+remaining_id).html(255 - $(input).val().length)
}
function post_mublog() {
  var mub = $('#mublog-new').val()
  mub = mub.replace(/^\s+/g, '')
  mub = mub.replace(/\s+$/g, '')
  if (mub.length) {
    $.post('/users/mublog/post', { 'mub': mub }, function() {
      window.location.reload(true);
    })
  }
}

function show_comment() {
  $('#comment-form-icon').hide();
  $('#comment-form').fadeIn();
  return false;
}
function cancel_comment() {
  $('#comment-form').hide();
  $('#comment-form-icon').fadeIn();
  return false;
}
