$().ready(function () {
    $(".ContactFormButton").click(function () {
        var valid = true;
        $("input,textarea").each(function () {
            if (this.className.indexOf("Required") >= 0) {

                $(this).removeClass("Error");

                var current = true;

                if (this.value.length == 0)
                    current = false;

                if (this.className.indexOf("Email") >= 0) {
                    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                    if (reg.test(this.value) == false)
                        current = false;
                }

                if (!current) {
                    $(this).addClass("Error");
                    valid = false;
                }
            }
        });

        return valid;
    });
});
