//this script was written by www.jooria.com for the puplic use
//the artilce link http://www.jooria.com/Tutorials/Website-Programming-16/Advanced-PHP-Comments-System-With-jQuery-155/index.html

(function($) {$.fn.jooria_comment = function(url){
    $(this).click(function() {
    //this the data that we will sent it 
    var name = $("#comments-box #name").val();
    $("#comments-box #name").val("");
    var mail = $("#comments-box #mail").val();
    $("#comments-box #mail").val("");
    var comment = $("#comments-box #comment").val();
    $("#comments-box #comment").val("");
    var page = $("#comments-box #purl").text();
    var dataString = 'name='+ name +'&mail='+ mail +'&comment='+ comment +'&purl='+page;

    //cool load system
    $("#comments-box button.submit").text('');
    $("#comments-box button.submit").css("background","#fff");
    $("#comments-box button.submit").html("<img src='includes/comments/style/loader.gif' />");    
    
    //post it now
    $.ajax({
    type: "POST",
    url: url,	
    data: dataString,
    cache: false,
    success: function(html){
    //this work on non-repeat the errors 
    var error = $("#comments-box ul#list li:last").attr("class");
    if ( error == "error"){$("#comments-box ul#list li:last").remove();}
    
    //if there is no comments
    $("#comments-box div#nocom").replaceWith("<ul id='list'></ul>");
    
    $("#comments-box ul#list").prepend(html);
    $("#comments-box ul#list li:last").fadeIn("slow");
    
    //restore the load to the normal
    $("#comments-box button.submit").html("");
    $("#comments-box button.submit").css("background","#ccc");
    $("#comments-box button.submit").text('Σχολίασε');
    }}
    );

    return false;
});
};
})(jQuery);

