$(function()
{
    enable_links_comment();

    apply_delete();
    
});

function enable_links_comment()
{
    $(".comment_link:not(.active)").toggle(function()
        {
            show_comment_form(this)
        },
        function()
        {
            hide_comment_form(this)
        }
    )
}

function hide_comment_form(link)
{
        $("#"+link.id.replace("comment_link", "feed_comments")).hide(500);
        $(link).removeClass( "active" );
}

function show_comment_form(link)
{
        $("#"+link.id.replace("comment_link", "feed_comments")).show(500);
        $(link).addClass( "active" );
}

function apply_delete(){
  $(".activity-delete").click(function() {
      var id = this.id.replace('feed_item_', '');
      //jQuery(this).parent().parent().fadeOut();
      jQuery.ajax({data:'_method=delete', dataType:'script', type:'post', url:'/users/<%=current_user.to_param%>/feed_items/' + id + '.js'});
      return false;
  });
}