if (typeof (window.ValidationSummary) == "undefined" || window.ValidationSummary == null) {
    window.ValidationSummary = Class.create();

    window.ValidationSummary.prototype =
    {
        initialize: function(elementID, params) {
            this.elementID = elementID;

            this.headerText = "Validation summary:"
            this.showMessageBox = true;
            this.showSummary = true;

            if (typeof (params) != "undefined")
                Object.extend(this, params);

            this.validators = new Array();
            this.element = document.getElementById(elementID);
            if (this.element != null)
                this.element.style.display = "none";
        },

        addValidator: function(validator) {
            this.validators.push(validator);
        },

        validate: function(groupName) {
            var scopeResult =
            {
                isValid: true,
                errorMessage: this.headerText + "\n",
                errorHtml: "",
                controlToFocus: null
            };

            try {
                for (var i = 0; i < this.validators.length; i++) {
                    if (!this.validators[i].validate(groupName)) {
                        if (scopeResult.isValid)
                            scopeResult.controlToFocus = this.validators[i].controlToValidate;

                        scopeResult.isValid = false;
                        scopeResult.errorMessage += " - " + this.validators[i].errorMessage + "\n";
                        scopeResult.errorHtml += this.validators[i].errorMessage + "<br />";
                    }
                }

                if (!scopeResult.isValid) {
                    if (this.showSummary && this.element != null) {
                        this.element.style.display = "block";
                        this.element.innerHTML = scopeResult.errorHtml;
                    }

                    if (this.showMessageBox)
                        alert(scopeResult.errorMessage);

                    if (scopeResult.controlToFocus != null)
                        scopeResult.controlToFocus.focus();

                    return false;
                }
                else {
                    return true;
                }
            }
            catch (e) {
                alert(e.message);
                return false;
            }
        }

    }

}