     $(document).ready(function(){
       $(".comment_button").click(function () {
            var id=$(this).parent().attr('id');
            var naam=$(this).parent().find('input[name=naam]').attr('value');
            var comment=$(this).parent().find('textarea[name=comment]').attr('value');
            var getal=$(this).parent().find('input[name=getal]').attr('value');
            {
            $.ajax(
                   {
                     url: "add_comment.php",
                     type: "POST",
                     data: { id:id, naam:naam,comment:comment,getal:getal },
                     cache: false,
                     success: function (response)
                        {
                           var target="#c"+id;               
                           
                           if(response=="no name")
                           {
                              $(target).load("comments.php",{topic:id}, function(){
                              $(".thisform").find('input[name=naam]').css('border','1px solid red');
                              $(".thisform").find('input[name=naam]').focus();
                              $(".thisform").find('input[name=naam]').val(naam);
                              $(".thisform").find('textarea[name=comment]').val(comment);
                              });
                           }
                           else if(response=="no comment")
                           {
                              $(target).load("comments.php",{topic:id}, function(){
                              $(".thisform").find('textarea[name=comment]').css('border','1px solid red');
                              $(".thisform").find('textarea[name=comment]').focus();
                              $(".thisform").find('input[name=naam]').val(naam);
                              $(".thisform").find('textarea[name=comment]').val(comment);
                              });
                           }
                           else if(response=="incorrect number")
                           {
                              $(target).load("comments.php",{topic:id}, function(){
                              $(".thisform").find('input[name=getal]').css('border','1px solid red');
                              $(".thisform").find('input[name=getal]').focus();
                              $(".thisform").find('input[name=naam]').val(naam);
                              $(".thisform").find('textarea[name=comment]').val(comment);
                              });
                           }                         
                           else
                           {
                             // alert(response);
                              $(target).load("comments.php",{topic:id});
                              $(target).prev().load('nr_of_comments.php', {id:id},function()
                                                    {
                                                        $(this).children('[class=load_comments]').hide();
                                                        $(this).children('[class=hide]').text('hide comment');
                                                        $(this).children('[class=hide]').addClass('comment_hide');
                                                     //   $(this).children('[class=hide]').html("<span class='hide 'class='comment_hide'>hide comments</span>")
                                                    });
                           }
                           
                        },
                        error: function (thrownError)
                        {
                           alert(thrownError);
                           var target="#c"+id;               
                           $(target).load("comments.php",{topic:id});
                        }
                  }
            );
            $(this).unbind();
            }
            return false;
         });
       });


         $(document).ready(function(){
       $(".hide").click(function () {
            $(this).prev().show();
           $(".comments_list").hide();
            $(this).hide();
            $(this).unbind();
            return false;
        });
       });

   $(document).ready(function(){
              $(".load_comments").click(function () {
                 $(".comments_list").hide();
                 $(".load_comments").show();
                  $(".hide").hide();
                 $(this).next().show();
//                  $(this).next().text("getting comments");
                  var Tid=$(this).attr("id");
                  var ids=Tid.split("_");
                  var id="c"+ids[1];
                  var target="#"+id;
                 $(target).empty().load("comments.php",{topic: ids[1]});
                 $(target).show();
                 $(this).hide();
                 $(this).next().text("hide comments");
                 $(this).next().addClass("comment_hide");
                 $(this).unbind();
                 return false;
              });
          });

//check wat gebeurt als unbind verwijderd                         
   $(document).ready(function(){
              $(".loadddddddd_comments").click(function () {
                 $(".comments_list").hide();
                 $(".load_comments").show();
                  $(".hide").hide();
                 $(this).next().show();
//                  $(this).next().text("getting comments");
                  var Tid=$(this).attr("id");
                  var ids=Tid.split("_");
                  var id="c"+ids[1];
                  var target="#"+id;
            //     alert(id);
                 $(target).load("comments.php",{topic: ids[1]});
                 $(target).show();
                 $(this).hide();
               //  $(this).next().html("<span class='comment_hide'>hide comments</span>");
                 $(this).next().text("hide comment");
                 $(this).next().addClass("comment_hide");
               //  $(this).unbind();
                 return false;
              });
          });          

