<!--

function CDIValidator()
{	
	// Global Variables
	this.ErrBackColor;this.ErrFontColor;this.ErrBorderColor;	
	this.GoodBackColor;this.GoodFontColor;this.GoodBorderColor;
	
	// Element Colors
	this.ErrBackColor = this.ErrBorderColor = "#393939";
	this.ErrFontColor = "White";
	this.GoodBackColor = this.GoodBorderColor = "a4a4a4";	
	this.GoodFontColor = "#393939";	
	
	// Regular Expressions
	this.NameExpression = new RegExp("[^a-zA-Z' '\']{1,}");
	this.EmailExpression = new RegExp("^[a-zA-Z0-9_+-]+(\.[a-zA-Z0-9_+-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.([a-zA-Z]{2,4})$");
	this.UserIDExpression = new RegExp("[]\"\'[\/~*(){}<>\\\\]{1,}");
	this.PhoneExpression = new RegExp("[0-9]{10}");
	this.PhoneOneExpression = new RegExp("[0-9]{3}");
	this.PhoneTwoExpression = new RegExp("[0-9]{4}");	
	this.CompanyExpression = new RegExp("[^a-zA-Z0-9' '\-]{1,}");
	this.AddressExpression = new RegExp("[]\-`\"\'[?\/~!@$%~&*(){}<>:;|+=,.'^'\\\\]{1,}");
	this.CityExpression = new RegExp("[^a-zA-Z' '\'.\-]");
	this.ZipExpression = new RegExp("[0-9]{5}");
	
	// Page Valid Property
	this.IsValid = true;	
		
	// UserID Validation
	this.ValidateUserID = function(userID){
		if(userID.value == ""){
			this.ErrorLog += "Missing UserID\n";this.IsValid = false;this.SetElemBad(userID);return;}
		if(userID.value.match(this.UserIDExpression)){
			this.ErrorLog += "Invalid UserID\n";this.IsValid = false;this.SetElemBad(userID);}}	
	
	// Email Address/UserName Validation
	this.ValidateEmail = function(emailAddress){
		if(emailAddress.value == ""){
			this.ErrorLog += "Missing Email Address/UserName\n";this.IsValid = false;this.SetElemBad(emailAddress);return;}
		if(!emailAddress.value.match(this.EmailExpression)){
			this.ErrorLog += "Invalid Email Address/UserName\n";this.IsValid = false;this.SetElemBad(emailAddress);}}
	
	// PassWord Validation
	this.ValidatePassWord = function(passWord){
		if(passWord.value == ""){
			this.ErrorLog += "Missing PassWord\n";this.IsValid = false;this.SetElemBad(passWord);return;}		
		if(passWord.value.match(this.UserIDExpression)){
			this.ErrorLog += "Invalid PassWord\n";this.IsValid = false;this.SetElemBad(passWord);}}
			
	// Validate Matching PassWords
	this.ValidateMatchingPassWords = function(password,pwdconfirm){
		if(password.value != pwdconfirm.value){
			this.IsValid = false;this.ErrorLog += "PassWords do not match\n";this.SetElemBad(password);this.SetElemBad(pwdconfirm);}}
			
	// Empty Validation
	this.ValidateEmpty = function(empty,input){
		if(empty.value == ""){
			this.IsValid = false;this.ErrorLog += "No " + input + " submitted\n";this.SetElemBad(empty);}}	
	
	// Basic Name Validation
	this.ValidateName = function(name,input){
		if(name.value.match(this.NameExpression)){
			this.ErrorLog += "Invalid or missing " + input + "\n";this.IsValid = false;this.SetElemBad(name);}}
	
	// Validate Company
	this.ValidateCompany = function(company){
		if(company.value != ""){
			if(company.value.match(this.CompanyExpression)){
				this.IsValid = false;this.ErrorLog += "Invalid Company name\n";this.SetElemBad(company);}}}
	
	// Validate Address
	this.ValidateAddress = function(address,addresstwo){		
		var theAddress = address.value + addresstwo.value;		
		if(theAddress != ""){			
			if(theAddress.match(this.AddressExpression)){
				this.IsValid = false;this.ErrorLog += "Invalid Address\n";
				if(address.value != ""){
					if(address.value.match(this.AddressExpression)){
						this.SetElemBad(address);}}
				if(addresstwo.value != ""){
					if(addresstwo.value.match(this.AddressExpression)){
						this.SetElemBad(addresstwo);}}}}}
	
	// Validate City
	this.ValidateCity = function(city){
		if(city.value != ""){
			if(city.value.match(this.CityExpression)){
				this.IsValid = false;this.ErrorLog += "Invalid City\n";this.SetElemBad(city);}}}		

	// Validate Zip
	this.ValidateZip = function(zip){
		if(zip.value != ""){		
			if(!zip.value.match(this.ZipExpression)){
				this.IsValid = false;this.ErrorLog += "Invalid Zip Code\n";this.SetElemBad(zip);
				return;}
			if(!zip.value.length > 5){
				this.IsValid = false;this.ErrorLog += "Invalid Zip Code\n";this.SetElemBad(zip);return;}}}			
	
	// Validate Phone Set
	this.ValidatePhone = function(phone,phonetwo,phonethree,name){		
		var phoneAll = phone.value + phonetwo.value + phonethree.value;
		if(phoneAll != ""){
			if(!phoneAll.match(this.PhoneExpression)){
				this.IsValid = false;this.ErrorLog += "Invalid " + name + "\n";
				if(!phone.value.match(this.PhoneOneExpression)){
					this.SetElemBad(phone);}
				if(!phonetwo.value.match(this.PhoneOneExpression)){
					this.SetElemBad(phonetwo);}
				if(!phonethree.value.match(this.PhoneTwoExpression)){
					this.SetElemBad(phonethree);}}}}	
	
	// Reset Error Log Method
	this.Reset = function(){
		this.ErrorLog = "Please Review the Following Errors\n\n";this.IsValid = true;}
	
	// Set Element Bad Function
	this.SetElemBad = function(elem){
		elem.style.backgroundColor = this.ErrBackColor;elem.style.color = this.ErrFontColor;}
}
//-->