$(document).ready(function(e){
    //$("#content").fadeIn(1000);
    $("#quote").show(500);
      /* BLOG */
  $(".post_comments").hide()
  $(".status_sent").hide()
  $(".post_comments_nbr").click(function(){
    $(this).next("div").slideToggle();
  })
   $(".comment_send").click(function(){
    var status=$(this).parent().children(".status_sent")
    status.hide();
    var name=$(this).parent().children("input[name=user_name]").val();
    name=name.trim();
    var comment=$(this).parent().children("textarea").val();
    comment=comment.trim();
    if(name=="" || comment==""){
      status.fadeIn();
      return;
    }
    var elementClicked=$(this);
    $.ajax({
      url:"/frontend_dev.php/blog/addComment",
      type:"POST",
      data:({post_id:$(this).parent().children("input[name=post_id]").val(),comment:$(this).parent().children("textarea").val(),user_name:name}),
      success:function(msg){
          elementClicked.parent().fadeOut(300, function(){
                elementClicked.parent().prev(".comments_container").append(msg);
                var newElement=  elementClicked.parent().prev(".comments_container").children("div:last")
                newElement.hide()
                newElement.fadeIn()
          })


      },
      error:function(XMLHttpRequest, textStatus, errorThrown){
            alert(XMLHttpRequest + " "+textStatus)

      }
    })
    ;

  })
})
