function post_click(){
    if($("#txtcomment").val() == ""){
        $("#comment_alert").html("Comment is empty").fadeIn();
        setTimeout(function(){
            $("#comment_alert").fadeOut()
        }, "3000");
    }else if($("#senderid").val() == ""){
        $("#comment_alert").html("You need to login to post a comment").fadeIn();
        setTimeout(function(){
            $("#comment_alert").fadeOut()
        }, "3000");
    }else{
        $("#btnpostcomment").attr("disabled", "true");
        $("#spinnerimg").fadeIn();
        var param = $("#comment").serialize();
        param += "&action=post_comment";
        $.post("func.ajax.php", param, function(data){
            $("#txtcomment").val("")
            //alert($("#tblcomment tr").length);
            if($("#tblcomment tr").length > 0){
                //alert("msuk len");
                $("#tblcomment tr:first").before(data);
            }else{
                //alert("msuk else");
                $("#tblcomment tr:first").html(data);
            }
            $("#tblcomment tr:first").fadeIn();
            $("#spinnerimg").fadeOut();
            $("#btnpostcomment").attr("disabled", "");
        });
    }

}

function delete_comment(commentid, pagetype){
    var param = {
        action: "delete_comment", 
        id: commentid,
        commenttype: pagetype
    };
    $.post("func.ajax.php", param, function(data){
        if(data == "true"){
            $("#" + commentid).fadeOut("slow");
            setTimeout(function(){
                $("#" + commentid).remove();
            }, 900);
        }else{
            $("#comment_alert").html("Comment deletion not successfull").fadeIn();
            setTimeout(function(){
                $("#comment_alert").fadeOut()
            }, "3000");
        }
    });
}

