  $(document).ready(function() {


             $(function() {
                 $(".textboxcon").focus(function() {
                     var idf = $(this).attr("id");
                     var idl = idf.substring(14);
                     $(this).animate({ "height": "55px" }, "fast");
                     $(".button_block2" + idl).slideDown("fast");
                     $("#commentbox" + idl).animate({ "height": "101px" }, "fast");
                     $("#commentbox" + idl).slideDown("fast");
                     return false;
                 });

                 $(".textboxcon").focusout(function() {

                     var value = $(this).val();
                     var idf = $(this).attr("id");
                     var idl = idf.substring(14);
                     if (value != "Write a comment") { }
                     else {

                         $(this).animate({ "height": "21px" }, "fast");
                         $(".button_block2" + idl).slideUp("fast");
                         $("#commentbox" + idl).animate({ "height": "40px" }, "fast");

                     }
                     return false;
                 });

             });


             $(".comment_submit").each(function() {

                 var Id = $(this).attr("id").substring(2);
                 var peng = $(this).attr("id").substring(0, 2);
                 var dataString2 = 'id=' + Id + '&peng=' + peng;


                 $.ajax({

                     type: "POST",
                     url: "../showmessages.php",
                     data: dataString2,
                     cache: false,
                     success: function(html) {

                         $("#loadplace" + Id).append(html);
                         $("#flash" + Id).hide();



                         var test2 = $(".msgclass" + Id).attr("id");
                         if (test2 != null) {
                             $("#commentbox" + Id).animate({ "height": "40px" }, "fast");
                             $("#commentbox" + Id).slideDown("fast");
                         }
						 
						 
        $(".delcom").click(function() {
            var element = $(this);
            var Id = element.attr("id");
            var dataString3 = 'delcom=' + Id;

            jConfirm('Are you sure you want ot delete this thread?', '',
    function(r) {
        if (r == true) {
            $.ajax({
                type: "POST",
                url: "../showmessages.php",
                data: dataString3,
                cache: false,
                success: function(html) {
					
                    $("#msgids" + Id).fadeOut(300);
                }
            });
        }
    });
        });
		
		
                         $(".delre").click(function() {

                             var element = $(this);
                             var Id2 = element.attr("id");
                             var dataString3 = 'delre=' + Id2;
                             jConfirm('Are you sure you want ot delete this thread?', '',
    function(r) {
        if (r == true) {
            $.ajax({
                type: "POST",
                url: "../showmessages.php",
                data: dataString3,
                cache: false,
                success: function(html) {
                    $("#msgids" + Id2).fadeOut(300);
                }

            });
        }
    });

                         });


                     }
                 });

             });


             $(".comment_submit").click(function() {
             var element = $(this);
             var Id = $(this).attr("id").substring(2);
             var peng = $(this).attr("id").substring(0, 2);

                 var test = $("#textboxcontent" + Id).val();

                 var Idmem = $("#Idmem" + Id).val();
                 var dataString = 'peng=' + peng + '&textcontent=' + test + '&com_msgid=' + Id + '&ownermem=' + Idmem;
              
                 if (test == '') {

                     alert("Please Enter Some Text");
                 }

                 else {

                     $("#flash" + Id).show();
                     $("#flash" + Id).fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> loading.....');


                     $.ajax({
                         type: "POST",
                         url: "../showmessages.php",
                         data: dataString,
                         cache: false,
                         success: function(html) {

                
      

                             $("#loadplace" + Id).append(html);
                             $("#flash" + Id).hide();
							 
							 
        $(".delcom").click(function() {
            var element = $(this);
            var Id = element.attr("id");
            var dataString3 = 'delcom=' + Id;

            jConfirm('Are you sure you want ot delete this thread?', '',
    function(r) {
        if (r == true) {
            $.ajax({
                type: "POST",
                url: "../showmessages.php",
                data: dataString3,
                cache: false,
                success: function(html) {
                    $("#msgids" + Id).fadeOut(300);
                }
            });
        }
    });
        });
		
		
                             $(".delre").click(function() {

                                 var element = $(this);
                                 var Id2 = element.attr("id");
                                 var dataString3 = 'delre=' + Id2;
                                 jConfirm('Are you sure you want ot delete this thread?', '',
    function(r) {
        if (r == true) {
            $.ajax({
                type: "POST",
                url: "../showmessages.php",
                data: dataString3,
                cache: false,
                success: function(html) {
                    $("#msgids" + Id2).fadeOut(300);
                }

            });
        }
    });

                             });
                         }
                     });
                     var idf = $(this).attr("id");
                     var idl = idf.substring(14);
                     $("#textboxcontent" + Id).val("Write a comment");
                     $(".textboxcon").animate({ "height": "21px" }, "fast");
                     $(".button_block2" + Id).slideUp("fast");
                     $("#commentbox" + Id).animate({ "height": "40px" }, "fast");

                 }


                 return false;
             });



         });
