/*****************************************\
|  This JavaScript include file contains  |
|  the DataValidator class that houses    |
|  all of the available data validation   |
|  rules.  Just create an instance of     |
|  this class, assign the test string,    |
|  then evaluate the specific test.       |
|                           - Doug Kelly  |
\*****************************************/

/*-------------------------------------------*\
|  All Regular Expressions Were Derived From  |
|  http://regexlib.com/Default.aspx           |
\*-------------------------------------------*/

function ValidatorType(strName, rgxTest)
{
	this.Name = strName;
	this.RegExp = rgxTest;
}

function StringValidator()
{
	this.testString = '';

	this.Types = new Array();
	this.Types[0] = new ValidatorType('Non-Zero Length String', /^.+$/);
	this.Types[1] = new ValidatorType('Email Address', /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/);
	this.Types[2] = new ValidatorType('Phone Number', /^[\\(]{0,1}([0-9]){3}[\\)]{0,1}[ ]?([^0-1]){1}([0-9]){2}[ ]?[-]?[ ]?([0-9]){4}[ ]*((x){0,1}([0-9]){1,5}){0,1}$/);
	this.Types[3] = new ValidatorType('Zip Code', /^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$/);

	this.evaluateRule = function(lngRuleIndex)
	{
		return this.evaluateCustom(this.Types[lngRuleIndex].RegExp);
	}

	this.evaluateCustom = function(strRegExp)
	{
		return strRegExp.test(this.testString);
	}
}
