$("input#recipe_comment_submit").live("click",function(){if(validate_recipe_comment_form()){$.post("comments.php",{a:"add",recipe_id:$("input#comment_recipe_id").val(),email:trim($("input#recipe_comment_mail").val()),nick:trim($("input#recipe_comment_nick").val()),c:trim($("textarea#recipe_comment").val())},function(data){$("div#tool").html(data);loadRecipe($("input#comment_recipe_id").val());$(window).scrollTop(60);},"html");}});$("img.delc").live("click",function(){if(confirm("Czy aby napewno chcesz usunąć ten komentarz?")){var gcomment_id=$(this).attr("id");$.post("comments.php",{a:"del",recipe_id:$("input#comment_recipe_id").val(),kill_code:$(this).attr("name"),comment_id:gcomment_id},function(data){$("div#tool").html(data);loadRecipe($("input#comment_recipe_id").val());$(window).scrollTop(60);},"html");}});function validate_recipe_comment_form(){$(".error").hide();var hasError=false;var emailReg=/^[a-zA-Z0-9._-]+\@([a-zA-Z0-9_-]+\.){1,}[\w]{1,4}$/;var nickToVal=trim($("input#recipe_comment_nick").val());if(nickToVal==""){$("div#recipe_comment_nick_error").html("Proszę się przedstawić.");hasError=true;}else{$("div#recipe_comment_nick_error").html("");}var emailToVal=trim($("input#recipe_comment_mail").val());if(emailToVal!=""&&!emailReg.test(emailToVal)){$("div#recipe_comment_mail_error").html("Proszę wpisać poprawny email.");hasError=true;}else{$("div#recipe_comment_mail_error").html("");}var commentToVal=trim($("textarea#recipe_comment").val());if(commentToVal==""){$("div#recipe_comment_error").html("Proszę wprowadzić komentarz.");hasError=true;}else{if(commentToVal.length>4096){$("div#recipe_comment_error").html("Komentarz nie może zawierać więcej niż 4096 znaków (to wystarczająco dużo).");hasError=true;}else{$("div#recipe_comment_error").html("");}}return !hasError;}