function show_comment_actions_button() { $(this).find('.actions').show(); }

function hide_comment_actions() { $(this).find('.actions').hide(); }

function toggle_comment_actions(sender) {
  target = $(sender).parent().parent().find('ul');
  if (target.css("display") == "none") {
    target.slideDown(100);
  } else {
    target.slideUp(100);
  }
  $(sender).toggleClass('active');
}

function return_to_regular_post() {
  $('#comment_body').focus();
  $('#new_comment .title').removeClass('private');
  $('#new_comment .title').removeClass('reply');
  $('#new_comment .title').html('Adelante, comenta. Estás en tu casa:');
  $('#comment_private_msg').val(0);
  $('#comment_references_user_fb_uid').val("");
  $('#comment_references_user_token').val("");
  $('#comment_references_user_nick').val("");
}

function reply_to_fb_uid(fb_uid) {
  $.scrollTo('#panel', 500);
  $('#comment_body').focus();
  $('#new_comment textarea').effect("highlight", {}, 2000);
  $('#new_comment .title').removeClass('private');
  $('#new_comment .title').addClass('reply');
  $('#new_comment .title').html('Respondiendo a <fb:name uid="' + fb_uid + '" linked="false" ifcantsee="Anónimo" useyou="false" firstnameonly="true"></fb:name> (<a href="javascript:return_to_regular_post()">Cancelar</a>):').pulsate();
  $('#comment_private_msg').val(0);
  $('#comment_references_user_fb_uid').val(fb_uid);
  $('#comment_references_user_token').val("");
  $('#comment_references_user_nick').val("");
  FB.XFBML.Host.parseDomTree();
}

function reply_to_user_token(nick, token) {
  $.scrollTo('#panel', 500);
  $('#comment_body').focus();
  $('#new_comment textarea').effect("highlight", {}, 2000);
  $('#new_comment .title').removeClass('private');
  $('#new_comment .title').addClass('reply');
  $('#new_comment .title').html('Respondiendo a ' + nick + ' (<a href="javascript:return_to_regular_post()">Cancelar</a>):').pulsate();
  $('#comment_private_msg').val(0);
  $('#comment_references_user_fb_uid').val("");
  $('#comment_references_user_token').val(token);
  $('#comment_references_user_nick').val(nick);
}

function private_msg_to_fb_uid(fb_uid) {
  $.scrollTo('#panel', 500);
  $('#comment_body').focus();
  $('#new_comment textarea').effect("highlight", {}, 2000);
  $('#new_comment .title').removeClass('reply');
  $('#new_comment .title').addClass('private');
  $('#new_comment .title').html('Mensaje privado a <fb:name uid="' + fb_uid + '" linked="false" ifcantsee="Anónimo" useyou="false" firstnameonly="true"></fb:name> (<a href="javascript:return_to_regular_post()">Cancelar</a>):').pulsate();
  $('#comment_references_user_fb_uid').val(fb_uid);
  $('#comment_private_msg').val(1);
  $('#comment_references_user_token').val("");
  $('#comment_references_user_nick').val("");
  FB.XFBML.Host.parseDomTree();
}

function private_msg_to_user_token(nick, token) {
  $.scrollTo('#panel', 500);
  $('#comment_body').focus();
  $('#new_comment textarea').effect("highlight", {}, 2000);
  $('#new_comment .title').removeClass('reply');
  $('#new_comment .title').addClass('private');
  $('#new_comment .title').html('Mensaje privado a ' + nick + ' (<a href="javascript:return_to_regular_post()">Cancelar</a>):').pulsate();
  $('#comment_private_msg').val(1);
  $('#comment_references_user_fb_uid').val("");
  $('#comment_references_user_token').val(token);
  $('#comment_references_user_nick').val(nick);
}

function send_to_facebook(comment_id, sender) {
  facebook_prompt_permission("publish_stream", null);
  $.post(comments_url + "/" + comment_id + "/send_to_facebook", {'authenticity_token' : form_auth_token});
  $(sender).parent().addClass('sent');
  $(sender).parent().html('<span class="disabled">Alehop! Kakoe enviado!</span>');
}

function send_to_twitter(comment_id, sender) {
  $.post(comments_url + "/" + comment_id + "/send_to_twitter", {'authenticity_token' : form_auth_token});
  $(sender).parent().addClass('sent');
  $(sender).parent().html('<span class="disabled">Alehop! Kakoe enviado!</span>');
}

function hide_user(url) {
  $.post(url);
  $('#comment_area').fadeOut();
}

function add_as_contact(fb_uid, sender) {
  $.post(contacts_url + "/", {'fb_uid' : fb_uid, 'authenticity_token' : form_auth_token});
  $('.change_contact_' + fb_uid).addClass('sent');
  $('.change_contact_' + fb_uid).html('<span class="disabled">Alehop! Contacto añadido!</span>').animate({opacity: '1'}, 2000).puff();
}