// Comment form validation

$(document).ready(function(){
    $("#comment_form").submit(function() {return validate_comment_form()});
});

    function validate_comment_form() {
        var errors = 0;
        var comment_field_ids = Array("#comment_name", "#comment_email", "#comment_title", "#comment_text");
        for (var i = 0; i < comment_field_ids.length; i++) {
            var field = ($(comment_field_ids[i]));
            if (field.attr("value").length == 0) {
                errors++;
                field.addClass("error");
            }
            else {
                field.removeClass("error");
            }
        }
        if (errors > 0) {
            $("#comment_errors").html("All fields are required.");
            return false;
        }
        return true;
    }
    
