	ValidatorDecorator.prototype = new ValidatorObject();

	ValidatorDecorator.constructor = ValidatorDecorator;
    ValidatorDecorator.baseConstructor = ValidatorObject;
	ValidatorDecorator.superclass = ValidatorObject.prototype;

    ValidatorDecorator.prototype.validatorObject = null;

	function ValidatorDecorator(defaultErrorMsg, validatorObject) {

        if(arguments.length > 0)
		{
           // Call the super() method of this class
           // (the ValidatorObject's constructor)
           ValidatorDecorator.baseConstructor.call(this, defaultErrorMsg);

           this.validatorObject = validatorObject;      
		}
	}

    // This function gets overriden by ValidatorDecorator
    // because of the way the Validation Decorators need to handle
    // validation.
    ValidatorDecorator.prototype.validate = function(id, errMsg)
    {
        // console.log("BEGIN: ValidatorDecorator.validate()");
        // 1. Call validate() on the validatorObject first.
        //    if this validation fails, it's error message will display,
        //    and this decorator won't bother to run it's test.
        var isValidField = this.validatorObject.validate(id, null);

        if(!isValidField)
        {
            // console.log("Right now I am doing nothing so that the correct error message displays!");
            // ----- DO NOTHING! -----
            // Don't bother to run the next test,
            // since we want to display the error
            // for the higher level (parent) validationObject.
        }
        else
        {
            // If the test of the higher level (parent) validationObject passed,
            // then run the test of the current ValidationDecorator, and if
            // it fails then display it's error message.
            isValidField = this.isValid(id);

            // Display an error or don't display an error depending on the
            // outcome of the test.
            if(isValidField)
            {
                this.toggleError(true, (id + "_ERR"), ((errMsg == null) ? this.defaultErrorMsg : errMsg));
            }
            else
            {
                this.toggleError(false, (id + "_ERR"), ((errMsg == null) ? this.defaultErrorMsg : errMsg));
            }
        }
        

        // console.log("END: ValidatorDecorator.validate()");
        return isValidField;
    };

	ValidatorDecorator.prototype.isValid = function(id) {
            // console.log("BEGIN: ValidatorDecorator.isValid()");
            // console.warn("isValid() is Abstract method and should be implemented in a subclass of ValidatorDecorator.");
            // console.log("END: ValidatorDecorator.isValid()");
            return true;
	};
