$(document).ready(function() {
    $(".form-reset-button").live("click", function() {
        var specialForm = $(this).parents("form:first");
        $("input", specialForm).each(function() {
            if ($(this).attr("name"))
                $(this).val("");
        });
    });

    $(".form-send-button").live("click", function() {
        try {
            var mailRc = $(this).attr("rc");
           
            var specialForm = $(this).parents("form:first");
            var errMsg = "";
            $("input, select, textarea", specialForm).each(function() {
                if (!$(this).attr("name"))
                    return;

                if ($(this).attr("required") == "true" && (typeof $(this).val() == "undefined" || (typeof $(this).val() == "string" && $(this).val().length == 0)))
                    errMsg += $(this).attr("Label") + ", ";

            });

            if (errMsg.length > 0)
                throw new Error("Es wurde nicht alle Pflichtfelder ausgefüllt: " + errMsg.substring(0, errMsg.length - 2));
			return true;
           
        }
        catch (e) {
            alert(e.description || e);
        }
        return false;
    });
});