
    PhoneValidator.prototype = new ValidatorDecorator();
    PhoneValidator.constructor = PhoneValidator;
    PhoneValidator.baseConstructor = ValidatorDecorator;
    PhoneValidator.superclass = ValidatorDecorator.prototype;

	function PhoneValidator(validatorObject, parensRequirement, separator, errMsg) {
		
        // TODO:
        if(arguments.length > 0)
		{
           // Call the super() method of this class
           // (the ValidatorDecorator's constructor)
            PhoneValidator.baseConstructor.call(this, errMsg, validatorObject);

			this.parenthesisRequirement = parensRequirement;
			this.separator = separator;

			// Phone Validator Constants
			this.REQUIRES_NO_PARENS = 2; // Requires no parenthesis around the area code.
			this.REQUIRES_PARENS = 1;    // Requires parenthesis around the area code.
			this.NO_REQUIRMENT = 0;      // Will accept both
		}
	}

	PhoneValidator.prototype.isValid = function(id) {
            // console.log("BEGIN: PhoneValidator.isValid()");

			var phoneField = document.getElementById(id);
			
            // Trim the string from the textbox and store it in phoneStr
            var phoneStr = Trim(phoneField.value);

			
			// // console.log("phoneField Id:" + id);
			// // console.log("this.parenthesisRequirement: " + this.parenthesisRequirement);

            // If the length of the phone number is greater than
            // zero, validate it, otherwise do not validate;
            //
            // The job of the PhoneValidator is to validate a valid
            // phone number, not to check if the field is blank.

            if(phoneStr.length > 0)
            {
                //
                // Build the regular expression string to validate this
                // field with:
                var regexString = "";


                if(this.parenthesisRequirement == this.REQUIRES_PARENS ||
                   this.parenthesisRequirement == this.NO_REQUIRMENT)
                {
                    regexString = regexString + "(\\(\\d{3}\\)" + this.separator + "\\d{3}" + this.separator + "\\d{4})";
                }

                if(this.parenthesisRequirement == this.NO_REQUIRMENT)
                {
                    regexString = regexString + "|";
                }

                if(this.parenthesisRequirement == this.REQUIRES_NO_PARENS ||
                   this.parenthesisRequirement == this.NO_REQUIRMENT)
                {
                    regexString = regexString + "(\\d{3}" + this.separator + "\\d{3}" + this.separator +"\\d{4})";
                }

                // // console.log("----------------------------------");
                // // console.log("regexSring: " + regexString);
                // // console.log("----------------------------------");

                var re = new RegExp(regexString);
                re.compile(regexString);

                validPhoneNumber = (re.test(phoneStr) == true) ? true : false;
            }
            else
            {
                // If the phone number is of length 0
                // (meaning there are no characters entered in the field)
                // then the phone number is valid because it is not the
                // phone validators job to check if the field is blank.
                //
                // That is the job of the NotBlankValidator if it is
                // used.
               validPhoneNumber = true;
            }

            // console.log("END: PhoneValidator.isValid()");
            return validPhoneNumber;
	};
