	// A simple Javascript class to be used 
	// as arguments into the blank validtor
	function ValidatorObject(defaultErrorMsg)
	{
		if(arguments.length > 0) {
			this.init(defaultErrorMsg);
		}
		
	}
	
	ValidatorObject.prototype.init = function(defaultErrorMsg) {
		this.defaultErrorMsg = defaultErrorMsg;
	};


	ValidatorObject.prototype.validate = function(id, errMsg)
	{
        // console.log("BEGIN: ValidatorObject.validate()");
        // 1. Call isValid (in the subclass) to see if the field is value
        // 2. Call toggleError to display or hide the error.

        var isValidField = this.isValid(id);

        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: ValidatorObject.validate()");
        return isValidField;
	};

    ValidatorObject.prototype.isValid = function(id, errMsg)
    { 
        // console.warn("This method should be overridden by a subclass");

        // By default it evalutes to true.
        return true;
    };

    // Toggles the display of the error message.
    //
    //  @param isValid - A boolean which
    //  @param errId   - The id of the HTML Element that
    //                   will display the error.
    //  @param errMsg  - The message that will be displayed
    //                   in the HTML Element when the error
    //                   is displayed.
    ValidatorObject.prototype.toggleError = function(isValid, errId, errMsg)
    {
        // console.log("BEGIN: ValidatorObject.toggleError()");
        if(isValid)
        {
                this.hideError(errId);
        }
        else
        {
                this.showError(errId, errMsg);
        }
        // console.log("END: ValidatorObject.toggleError()");
    };

    // This method can be overriden to do anything
    // that you might want when you show the error.
    //
    // The default behavior is to...
    ValidatorObject.prototype.showError = function(err_id, errMsg)
    {
        // console.log("BEGIN: ValidatorObject.showError()");
        var fieldError = document.getElementById(err_id);

        fieldError.innerHTML = errMsg;
        fieldError.style.visibility = "visible";
        fieldError.style.display = "block";
        // console.log("END: ValidatorObject.showError()");
    };

    // This method can be overriden to do anything
    // that you might want when you hide the error.
    //
    // The default behavior is to...
    ValidatorObject.prototype.hideError = function(err_id)
    {
        // console.log("BEGIN: ValidatorObject.hideError()");
        var fieldError = document.getElementById(err_id);

        fieldError.innerHTML = "";
        fieldError.style.visibility = "hidden";
        fieldError.style.display = "none";
        // console.log("END: ValidatorObject.hideError()");
    };

    