function ElementValidator(argFormName, argElementName, argRegExpPattern, argMessageIfNotValid )
{
	this.formName = argFormName;
	this.elementName = argElementName;
	this.regExpPattern = argRegExpPattern;
	this.messageIfNotValid = argMessageIfNotValid;
	this.isValid = ElementValidator_isValid; // method!!
}

function ElementValidator_isValid()
{
	// inside a method, use ElementValidator Properties
	// get the text for this element
	var textOfElement = 
	document.forms[this.formName].elements[this.elementName].value;
	// create a RegExp Object using our pattern
	var reg = new RegExp(this.regExpPattern);

	// test the Regular Expression, return the result
	return reg.test(textOfElement);
}

function FormValidator()
{
	this.elementValidators = new Array();
	this.add = FormValidator_add; // methods!!
	this.validate = FormValidator_validate;
}

// add method
function FormValidator_add(argElementValidator)
{
	var newIndex = this.elementValidators.length;
	this.elementValidators[newIndex] = argElementValidator;
}

// validate method
function FormValidator_validate()
{
	// number of items to validate
	var count = this.elementValidators.length;
	// step through the elementValidators
	for (var i = 0 ; i < count ; i++)
	{
		// if an element not valid
		if (!this.elementValidators[i].isValid())
		{
			window.alert(this.elementValidators[i].messageIfNotValid)
			return false;
		}
	}
	// we made it through, so all are OK!
	return true;
}
