// js for comment/form
jQuery(function() {   
    // comment
    var commentValidator = $('#formComment').validate({
        rules: {
            name: "required",
            email: { 
                required: true, 
                email: true
            },
            content: "required",
            "captcha[input]": "required"
        },
        messages: {
            name: "Geben Sie Ihren Namen an",
            email: {
                required: "Geben Sie Ihre E-Mail Adresse an",
                email: "Geben Sie eine gültige E-Mail Adresse an"
            },
            content: "Geben Sie einen Kommentartext ein",
            "captcha[input]" : "Geben Sie den Sicherheitscode ein"
        },
        submitHandler: function(form) {
            var commentForm = $(form);
            var formData = commentForm.serializeArray();
        
            // TODO kein alert sondern richtige rückgabe
            $.post(commentForm.attr('action'), formData, function(data) {
                var documentNode = $('div.document-comment-form').parent();
                //console.log ( documentNode );
                $('div.document-comment-form').remove();
                documentNode.append( $(data) );
            })
        }
    })
});
