<!--
/**
	Simply include this file, this attaches to all documents in a page. **This will only enforce validation if one of the following items is set upon the elements of the page.
	
	**NOTE: any one or more of these options can be set and they do build upon each other.
	
	Globals:
	errorTextBoxBackgroundColor = SomeHex color		-- when a field has an error this changes the backgroundcolor for textboxes and password types
	
	validation is required by attributes to the html elements the following attributes and types are supported.
	
	<input type="password"
		required=true/false							--	Requires field if true

		requiredErrorMessage="My custom error"		--	Overrides the default REQUIRED error message

		DisplayName="My Display Name Error"			--	Allows you to override the name element of the field and provide a more readable field identifier

		compareID=mypassword						--	This uniqueID must be in EACH of the password types to be compared, if not required will only compare if filled in

		requiredErrorMessag="my message"			--	Overrides default error message

		minLength="5"								--	Min number of characters if filled out.

		minLengthErrorMessage="My custom error"		--	Overrides the default MIN LENGTH error message
	>
	
	<input type="text"
		required="true/false"						--	Requires field if true

		requiredErrorMessage="My custom error"		--	Overrides the default REQUIRED error message

		DisplayName="My Display Name Error"			--	Allows you to override the name element of the field and provide a more readable field identifier

		numeric="true/false"						--	Strips non-numeric out of the field

		numericErrorMessage="My custom error"		--	Overrides the default error message if it is not numeric

		numericmask="true/false"					--	$##.## use # for numeric locations, evaluates that at least the number of numeric characters = the same number of # (Does not strip out formating IF numeric=false. If stripping is needed set numeric=true

		numericmaskErrorMessage="my custom error"	--	Overrides the default error message for numeric mask.

		compareID=mycompareuniqueid					--	This uniqueID must be in EACH of the password types to be compared, if not required will only compare if filled in

		IsEmail="true/false"						--	Evaluates for standard email address

		IsEmailErrorMessage="my custom error"		--	Overrides the default error message for email error messages.

		IsUSPhone="true/false"						--	Evaluates 10 digit phone numbers. Basically forces Numeric=true, numericmask=(###) ###-####

		IsUSPhoneErrorMessage="my custom error"		--	Overrides the default IsUSPhone Error Message. 

		minLength="5"								--	Min number of characters if filled out.

		minLengthErrorMessage="My custom error"		--	Overrides the default MIN LENGTH error message

		isDecimal="true/false"						--	Requires numericMask with a decimal
														**VOIDS minLength use compareMinValue and Compare Max value instead

		compareMaxValue="value"						--	Sets the max value of the textbox, complements numeric, isdecimal and "string"
														**VOIDS minLength
		compareMaxValueErrorMessage="custerror"		--	Overrides the default Max Value Error message
														**ACCEPTS String Parameters of @VALUEOF (inputed value) and @MAXRATE (max rate setting)
														
		compareMinValue="value"						-- Sets the min value of the textbox, complements numeric, isdecimal and "string"
														**VOIDS minLength
		compareMinValueErrorMessage="custerror"		--	Overrides the default Min Value Error message
														**ACCEPTS String Parameters of @VALUEOF (inputed value) and @MINRATE (max rate setting)
	>


	
	
	** Example: <input type="text" 
					required="true" 
					DisplayName="Total" 
					name="txtTotal"
					numericmask="$#.##"
				>
		Validation if submitted with no value would inform the client that:
			Total is required.
		
		Client then types in 0
		
		Validation then states that the min length is 3.
		
		Client then types 0.00: Same issue 0 is invalid
		
		Client then types 001: Evaluates and displays $0.01 and submits successfully.
		
		
**/
// Debugging vars
var blnVerboseDebug = false;
var blnDebug = true;
var displayVersioning = false;
// Global configuration
var errorTextBoxBackgroundColor = "#d8bfd8";
var errorSelectBoxBackgroundColor = "#d8bfd8";
var errorCheckBoxBackgroundColor = "#d8bfd8";
var errorCheckBoxBackgroundColorDefault = "#ffffff";
var errorRadioButtonBackgroundColor = "#d8bfd8";
var errorRadioButtonBackgroundColorDefault = "#ffffff";

var errorFileBackgroundColor = "#d8bfd8";

function oValidation() {
	// Version Properties
	this.Version = new oVersion(this);
	// Properties
	this.name = "oValidation";
	this.arPasswordID = new Array();
	this.arCompareID = new Array();
	this.formValid = true;
	
	// Error Colors
	this.errorTextBoxBackgroundColor = errorTextBoxBackgroundColor;
	this.errorSelectBoxBackgroundColor = errorSelectBoxBackgroundColor;
 	this.errorCheckBoxBackgroundColor = errorCheckBoxBackgroundColor;
 	this.errorCheckBoxBackgroundColorDefault = errorCheckBoxBackgroundColorDefault;
 	this.errorRadioButtonBackgroundColor = errorRadioButtonBackgroundColor;
 	this.errorRadioButtonBackgroundColor = errorRadioButtonBackgroundColor;
 	this.errorFileBackgroundColor = errorFileBackgroundColor;
	
	this.focusSet = false;
	// Objects
	this.Enums = new oEnums(this);
	var _obj = this; // Local for scope confusion
	this.Functions = new oFunctions(this);
	this.Messages = new oMessages(this);
	// Methods
	this.validate =
		// Main Validation method
		function (form) {
			var elem = form.elements;
			_obj.form = form;
			_obj.Messages.message = "";
			_obj.arPasswordID = new Array();
			_obj.arCompareID = new Array();
			_obj.focusSet = false;
			_obj.formValid = true;
			for (var i=0;i<elem.length;i++) {
				switch (elem[i].type) {
					case "text":
						// text type validations
						var _textbox = new oTextBox(_obj, elem[i]);
						if (!_textbox.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_textbox.focus()) {
									_obj.focusSet = true;
								}
							}
						}
					break;
					case "select-multiple":
						// select-multiple validations
						var _select = new oSelect(_obj, elem[i]);
						if (!_select.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_select.focus()) {
									_obj.focusSet = true;
								}
							}
						}
					break;
					case "select-one":
						// select-one validations
						var _select = new oSelect(_obj, elem[i]);
						if (!_select.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_select.focus()) {
									_obj.focusSet = true;
								}
							}
						}
					break;
					case "password":
						// password validations
						var _password = new oPassword(_obj, elem[i]);
						if (!_password.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_password.focus()) {
									_obj.focusSet = true;
								}
							}
						}
					break;
					case "checkbox":
						// checkbox validations
						var _checkbox = new oCheckbox(_obj, elem[i]);
						if (!_checkbox.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_checkbox.focus()) {
									_obj.focusSet = true;
								}
							}
						} 
						
				break;
					case "textarea":
						// textarea validations
						var _textarea = new oTextArea(_obj, elem[i]);
						if (!_textarea.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_textarea.focus()) {
									_obj.focusSet = true;
								}
							}
						}
					break;
					case "file":
						// file validations
						var _file = new oFile(_obj, elem[i]);
						if (!_file.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_file.focus()) {
									_obj.focusSet = true;
								}
							}
						}
					break
					case "radio":
						// radio validations
						var _radio = new oRadio(_obj, elem[i]);
						if (!_radio.validate()) {
							_obj.formValid = false;
							if (!_obj.focusSet) {
								if (_radio.focus()) {
									_obj.focusSet = true;
								}
							}
						} 
					break
					default:
					break;
				}
			
			}
			if (_obj.Messages.message != "") {
				_obj.Messages.displayMessage();
			}
			return _obj.formValid;
			
		}
		
		this.doDisplayOnElements = 
			function () {
				var elem = _obj.form.elements;
				
				for (var i=0;i<elem.length;i++) {
					switch (elem[i].type) {
						case "text":
							// text type formating
							var _textbox = new oTextBox(_obj, elem[i]);
							_textbox.doDisplay();
							if (!_obj.focusSet) {
								if (_textbox.focus()) {
								_obj.focusSet = true;
								}
							}

						break;
						case "select-multiple":
							// select-multiple formating
							var _selectmulti = new oSelect(_obj, elem[i]);
							if (!_obj.focusSet) {
								if (_selectmulti.focus()) {
									_obj.focusSet = true;
								}
							}
						break;
						case "select-one":
							// select-one formating
							var _select = new oSelect(_obj, elem[i]);
							_select.doDisplay();
							if (!_obj.focusSet) {
								if (_select.focus()) {
									_obj.focusSet = true;
								}
							}
						break;
						case "password":
							// password formating
							var _password = new oPassword(_obj, elem[i]);
							if (!_obj.focusSet) {
								if (_password.focus()) {
									_obj.focusSet = true;
								}
							}
						break;
						case "checkbox":
							// checkbox formating
							var _checkbox = new oCheckbox(_obj, elem[i]);
							if (!_obj.focusSet) {
								if (_checkbox.focus()) {
									_obj.focusSet = true;
								}
							}
						break;
						case "textarea":
							// textarea formating
							var _textarea = new oTextArea(_obj, elem[i]);
							if (!_obj.focusSet) {
								if (_textarea.focus()) {
									_obj.focusSet = true;
								}
							}
						break;
						case "file":
							// file formating
							var _file = new oFile(_obj, elem[i]);
							if (!_obj.focusSet) {
								if (_file.focus()) {
									_obj.focusSet = true;
								}
							}
						break;
						case "radio":
							// radio formating
							var _radio = new oRadio(_obj, elem[i]);
							if (!_obj.focusSet) {
								if (_radio.focus()) {
									_obj.focusSet = true;
								}
							}
						break;
						default:
						break;
					}
				
				}
				
			}
	
		this.setEventsForNumericMask = 
			function () {
				var elem = _obj.form.elements;
				for (var i=0;i<elem.length;i++) {
					switch (elem[i].type) {
						case "text":
							// text type validations
							var _textbox = new oTextBox(_obj, elem[i]);
							_textbox.setEventsForNumericMask();
						break;
						case "select-multiple":
							// select-multiple validations
						break;
						case "select-one":
							// select-one validations
						break;
						case "password":
							// password validations
							//_password.validate();
						break;
						case "checkbox":
							// checkbox validations
						break;
						case "textarea":
							// textarea validations
						break;
						case "file":
							// file validations
						break
						case "radio":
							// radio validations
						break
						default:
						break;
					}
				
				}
				
			}
			
	// Initialization
		this.addEventstoDocuments =
		function () {
			for (var i = 0;i<document.forms.length;i++) {
				_obj.Functions.addsubmitEvent(document.forms[i],_obj.validate);
				_obj.form = document.forms[i];
				_obj.doDisplayOnElements();
				_obj.setEventsForNumericMask();
			}
		}
	_obj.Functions.addloadEvent(_obj.addEventstoDocuments)

}

function oTextArea(parent, elem) {
	// Version Properties
	this.Verison = new oVersion(this);
	
	// Objects
	var _obj = this; // Local for scope
	
	// Properties
	this.name = "oTextArea";
	this.errorBackgroundColor = parent.errorFileBackgroundColor;

	this.formCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("FormCheckerID"))) {
		if (elem.getAttribute("FormCheckerID").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("FormCheckerID").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("name"))) {
		if (elem.getAttribute("name").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("name").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("id").toString().toLowerCase();
		}
	}

	
	this.required = false;
	if (parent.Functions.notNull(elem.getAttribute("Required"))) {
		if (elem.getAttribute("Required").toString().toLowerCase() == "true") {
			_obj.required = true;
		}
	}
	this.requiredErrorMessage = "is required.";
	if (parent.Functions.notNull(elem.getAttribute("RequiredErrorMessage"))) {
		if (elem.getAttribute("RequiredErrorMessage").toString().toLowerCase() != "") {
			_obj.requiredErrorMessage = elem.getAttribute("RequiredErrorMessage").toString();
		}
	}

	this.displayname = "";
	if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("id").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("Name"))) {
		if (elem.getAttribute("Name").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("Name").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("DisplayName"))) {
		if (elem.getAttribute("DisplayName").toString().toLowerCase() != "") {
			_obj.displayname = elem.getAttribute("DisplayName").toString();
		}
	}

	this.setBackgroundColor =
		function () {
			//elem.style.backgroundColor = "purple";
			elem.style.backgroundColor = _obj.errorBackgroundColor;
		}

	this.clearBackgroundColor = 
		function () {
			elem.style.backgroundColor = "";
		}
		
	this.focus =
		function () {
			try {
				elem.focus();
				return true;
			}
			catch(ex) {
				return false;
			}
		}
	this.doDisplay =
		function () {
			// Get rid of annoying newline and tabs caused from HTML formating
			
			if (elem.value.replace(/\t|\r|\n/g, "").length == 0) {
				elem.value = elem.value.replace(/\t|\r|\n/g, "")
			}
		}

	this.validate =
		function (displayError) {
			var _displayErrorUI = false;
			
			var ext;
			if (!parent.Functions.notNull(displayError)) {
				_displayErrorUI = true;
			}
			else {
				if (displayError.toString().toLowerCase() == "true") {
					_displayErrorUI = true;
				}
			}
			
			if (_displayErrorUI) {_obj.setBackgroundColor();}
			if (_obj.required) {
				if (elem.value.replace(/\t|\r|\n/g, "").length == 0) {
					elem.value = elem.value.replace(/\t|\r|\n/g, "")
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.requiredErrorMessage);}
					return false;
				}
			}
		
		
			if (_displayErrorUI) {_obj.clearBackgroundColor();}
			return true;
		}
}

function oFile(parent, elem) {
	// Version Properties
	this.Verison = new oVersion(this);
	
	// Objects
	var _obj = this; // Local for scope
	
	// Properties
	this.name = "oFile";
	this.errorBackgroundColor = parent.errorFileBackgroundColor;

	this.formCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("FormCheckerID"))) {
		if (elem.getAttribute("FormCheckerID").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("FormCheckerID").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("name"))) {
		if (elem.getAttribute("name").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("name").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("id").toString().toLowerCase();
		}
	}

	this.required = false;
	if (parent.Functions.notNull(elem.getAttribute("Required"))) {
		if (elem.getAttribute("Required").toString().toLowerCase() == "true") {
			_obj.required = true;
		}
	}
	this.requiredErrorMessage = "is required.";
	if (parent.Functions.notNull(elem.getAttribute("RequiredErrorMessage"))) {
		if (elem.getAttribute("RequiredErrorMessage").toString().toLowerCase() != "") {
			_obj.requiredErrorMessage = elem.getAttribute("RequiredErrorMessage").toString();
		}
	}

	this.displayname = "";
	if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("id").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("Name"))) {
		if (elem.getAttribute("Name").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("Name").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("DisplayName"))) {
		if (elem.getAttribute("DisplayName").toString().toLowerCase() != "") {
			_obj.displayname = elem.getAttribute("DisplayName").toString();
		}
	}

	this.fileTypes = "";
	if (parent.Functions.notNull(elem.getAttribute("FileTypes"))) {
		if (elem.getAttribute("FileTypes").toString().toLowerCase() != "") {
			_obj.fileTypes = elem.getAttribute("FileTypes").toString();
		}
	}
	this.fileTypesErrorMessage = "must be one of the following filetypes: @FILETYPES";
	if (parent.Functions.notNull(elem.getAttribute("FileTypesErrorMessage"))) {
		if (elem.getAttribute("FileTypesErrorMessage").toString().toLowerCase() != "") {
			_obj.fileTypesErrorMessage = elem.getAttribute("FileTypesErrorMessage").toString();
		}
	}
	
	// Methods
	this.setBackgroundColor =
		function () {
			//elem.style.backgroundColor = "purple";
			elem.style.backgroundColor = _obj.errorBackgroundColor;
		}

	this.clearBackgroundColor = 
		function () {
			elem.style.backgroundColor = "";
		}
		
	this.focus =
		function () {
			try {
				elem.focus();
				return true;
			}
			catch(ex) {
				return false;
			}
		}
	
	this.validate =
		function (displayError) {
			var _displayErrorUI = false;
			var _elements;
			var _match = false;
			var arFileTypes;// = new Array();
			
			var ext;
			if (!parent.Functions.notNull(displayError)) {
				_displayErrorUI = true;
			}
			else {
				if (displayError.toString().toLowerCase() == "true") {
					_displayErrorUI = true;
				}
			}
			
			if (_displayErrorUI) {_obj.setBackgroundColor();}
			
			if (_obj.fileTypes != "") {
				arFileTypes = _obj.fileTypes.split(",");
			}

			if (elem.value.length !=0 && _obj.fileTypes != "") {
				for (var i = 0;i<arFileTypes.length;i++) {
					if (elem.value.substring(elem.value.length-arFileTypes[i].toString().length,elem.value.length).toLowerCase() == arFileTypes[i].toString().toLowerCase()) {
						_match = true;
					}
				}
				if (!_match) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.fileTypesErrorMessage.replace('@FILETYPES', _obj.fileTypes));}
					return false;
				}
			}
			
			if (_obj.required) {
				for (var i = 0;i<arFileTypes.length;i++) {
					if (elem.value.substring(elem.value.length-arFileTypes[i].toString().length,elem.value.length).toLowerCase() == arFileTypes[i].toString().toLowerCase()) {
						_match = true;
					}
				}
				if (elem.value == "") {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.requiredErrorMessage);}
					return false;
				}
				if (!_match) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.fileTypesErrorMessage.replace('@FILETYPES', _obj.fileTypes));}
					return false;
				}
			}

		if (_displayErrorUI) {_obj.clearBackgroundColor();}
		return true;
	}
}

function oRadio(parent, elem) {
	// Version Properties
	this.Verison = new oVersion(this);
	
	// Objects
	var _obj = this; // Local for scope
	
	// Properties
	this.name = "oRadio";
	this.errorBackgroundColor = parent.errorRadioButtonBackgroundColor;

	this.formCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("FormCheckerID"))) {
		if (elem.getAttribute("FormCheckerID").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("FormCheckerID").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("name"))) {
		if (elem.getAttribute("name").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("name").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("id").toString().toLowerCase();
		}
	}

	this.required = false;
	if (parent.Functions.notNull(elem.getAttribute("Required"))) {
		if (elem.getAttribute("Required").toString().toLowerCase() == "true") {
			_obj.required = true;
		}
	}
	this.requiredErrorMessage = "is required.";
	if (parent.Functions.notNull(elem.getAttribute("RequiredErrorMessage"))) {
		if (elem.getAttribute("RequiredErrorMessage").toString().toLowerCase() != "") {
			_obj.requiredErrorMessage = elem.getAttribute("RequiredErrorMessage").toString();
		}
	}

	this.minNumberOfItemsChecked = 0;


	this.displayname = "";
	if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("id").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("Name"))) {
		if (elem.getAttribute("Name").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("Name").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("DisplayName"))) {
		if (elem.getAttribute("DisplayName").toString().toLowerCase() != "") {
			_obj.displayname = elem.getAttribute("DisplayName").toString();
		}
	}

	// Methods
	this.setBackgroundColor =
		function () {
			//elem.style.backgroundColor = "purple";
			elem.parentElement.style.backgroundColor = _obj.errorBackgroundColor;
		}

	this.clearBackgroundColor = 
		function () {
			elem.parentElement.style.backgroundColor = errorCheckBoxBackgroundColorDefault;
		}
		
	this.focus =
		function () {
			try {
				elem.focus();
				return true;
			}
			catch(ex) {
				return false;
			}
		}
	
	this.validate =
		function (displayError) {
			var _formcheckeritem = false;
			var _displayErrorUI = false;
			var _elements;
			
			if (!parent.Functions.notNull(displayError)) {
				_displayErrorUI = true;
			}
			else {
				if (displayError.toString().toLowerCase() == "true") {
					_displayErrorUI = true;
				}
			}
			
			if (_obj.required) {
				_count = 0;
				_formcheckeritem = true;
				if (_obj.minNumberOfItemsChecked == 0) {_obj.minNumberOfItemsChecked = 1;}
				_obj.setBackgroundColor();

				if (elem.checked) {_count++}
				_elements = parent.Functions.getFormCheckerItems(_obj.formCheckerID, parent.form);
				for (var i=0;i<_elements.length;i++) {
					if (_elements[i].checked && _elements[i].type == "radio") {
						if (elem != _elements[i]) {
							_count++;
							_foundall = true;
						}
					}
				}
				
				
				if (_count < _obj.minNumberOfItemsChecked && (_count != 0 || _obj.required)) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.requiredErrorMessage);}
					return false;
				}
			}

						
			if (_formcheckeritem && _displayErrorUI) {_obj.clearBackgroundColor();}
			
			return true;
		}
		
}

function oCheckbox(parent, elem) {
	// Version Properties
	this.Version = new oVersion(this);
	
	// Objects
	var _obj = this; // Local for scope
	
	// Properties
	this.name = "oCheckbox";
	this.errorBackgroundColor = parent.errorCheckBoxBackgroundColor;

	this.formCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("FormCheckerID"))) {
		if (elem.getAttribute("FormCheckerID").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("FormCheckerID").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("name"))) {
		if (elem.getAttribute("name").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("name").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("id").toString().toLowerCase();
		}
	}

	this.required = false;
	if (parent.Functions.notNull(elem.getAttribute("Required"))) {
		if (elem.getAttribute("Required").toString().toLowerCase() == "true") {
			_obj.required = true;
		}
	}
	this.requiredErrorMessage = "is required.";
	if (parent.Functions.notNull(elem.getAttribute("RequiredErrorMessage"))) {
		if (elem.getAttribute("RequiredErrorMessage").toString().toLowerCase() != "") {
			_obj.requiredErrorMessage = elem.getAttribute("RequiredErrorMessage").toString();
		}
	}

	this.minNumberOfItemsChecked = 0;
	if (parent.Functions.notNull(elem.getAttribute("MinNumberOfItemsChecked"))) {
		if (elem.getAttribute("MinNumberOfItemsChecked").toString().replace(/\D+/g, "") != "") {
			_obj.minNumberOfItemsChecked = elem.getAttribute("MinNumberOfItemsChecked").toString().replace(/\D+/g, "");		
		}
	}
	
	this.minNumberOfItemsCheckedErrorMessage = "must have at least @MINNUMBERCHECKED chosen.";
	if (parent.Functions.notNull(elem.getAttribute("MinNumberOfItemsCheckedErrorMessage"))) {
		if (elem.getAttribute("MinNumberOfItemsCheckedErrorMessage").toString().replace(/\D+/g, "") != "") {
			_obj.minNumberOfItemsCheckedErrorMessage = elem.getAttribute("MinNumberOfItemsCheckedErrorMessage").toString().replace(/\D+/g, "");		
		}
	}

	this.maxNumberOfItemsChecked = 0;
	if (parent.Functions.notNull(elem.getAttribute("MaxNumberOfItemsChecked"))) {
		if (elem.getAttribute("MaxNumberOfItemsChecked").toString().replace(/\D+/g, "") != "") {
			_obj.maxNumberOfItemsChecked = elem.getAttribute("MaxNumberOfItemsChecked").toString().replace(/\D+/g, "");		
		}
	}
	this.maxNumberOfItemsCheckedErrorMessage = "cannot have more then @MAXNUMBERCHECKED chosen.";
	if (parent.Functions.notNull(elem.getAttribute("MaxNumberOfItemsCheckedErrorMessage"))) {
		if (elem.getAttribute("MaxNumberOfItemsCheckedErrorMessage").toString().replace(/\D+/g, "") != "") {
			_obj.maxNumberOfItemsCheckedErrorMessage = elem.getAttribute("MaxNumberOfItemsCheckedErrorMessage").toString().replace(/\D+/g, "");		
		}
	}

	this.displayname = "";
	if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("id").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("Name"))) {
		if (elem.getAttribute("Name").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("Name").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("DisplayName"))) {
		if (elem.getAttribute("DisplayName").toString().toLowerCase() != "") {
			_obj.displayname = elem.getAttribute("DisplayName").toString();
		}
	}
	
	this.checked = elem.checked;	
	// Methods
	this.setBackgroundColor =
		function () {
			//elem.style.backgroundColor = "purple";
			elem.parentElement.style.backgroundColor = _obj.errorBackgroundColor;
		}

	this.clearBackgroundColor = 
		function () {
			elem.parentElement.style.backgroundColor = errorCheckBoxBackgroundColorDefault;
		}
		
	this.focus =
		function () {
			try {
				elem.focus();
				return true;
			}
			catch(ex) {
				return false;
			}
		}
	
	
	this.validate =
		function (displayError) {
			var _count = 0;
			var _elements;
			var _foundall = false;
			var _formcheckeritem = false;
			var _displayErrorUI = false;
			
			if (!parent.Functions.notNull(displayError)) {
				_displayErrorUI = true;
			}
			else {
				if (displayError.toString().toLowerCase() == "true") {
					_displayErrorUI = true;
				}
			}
			
			if (_obj.required || _obj.minNumberOfItemsChecked != 0 || _obj.maxNumberOfItemsChecked != 0) {
				_formcheckeritem = true;
			}
			
			if (_formcheckeritem && _displayErrorUI) {_obj.setBackgroundColor();}

			if (_obj.required) {
				if (_obj.minNumberOfItemsChecked == 0) {_obj.minNumberOfItemsChecked = 1;}
			}

			if (_obj.minNumberOfItemsChecked > 0) {
				_count = 0;
				
				if (elem.checked) {_count++}
				_elements = parent.Functions.getFormCheckerItems(_obj.formCheckerID, parent.form);
				for (var i=0;i<_elements.length;i++) {
					if (_elements[i].checked && _elements[i].type == "checkbox") {
						if (elem != _elements[i]) {
							_count++;
							_foundall = true;
						}
					}
				}
				
				
				if (_count < _obj.minNumberOfItemsChecked && (_count != 0 || _obj.required)) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.minNumberOfItemsCheckedErrorMessage.replace('@MINNUMBERCHECKED', _obj.minNumberOfItemsChecked));}
					return false;
				}
				
				if (_count > _obj.maxNumberOfItemsChecked && _obj.maxNumberOfItemsChecked != 0) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.maxNumberOfItemsCheckedErrorMessage.replace('@MAXNUMBERCHECKED', _obj.maxNumberOfItemsChecked));}
					return false;
				}


			}
			
			if (_formcheckeritem && _displayErrorUI) {_obj.clearBackgroundColor();}

			return true;
		}
			
	
	// Initalization
	
}

function oSelect(parent, elem) {
	// Version Properties
	this.Version = new oVersion(this);
	
	// Objects
	var _obj = this; // Local for scope
	
	// Properties
	this.name = "oSelect";
	this.errorBackgroundColor = parent.errorSelectBoxBackgroundColor;
	this.selectMultipal = false;
	if (elem.type == "select-multiple") {
		_obj.selectMultipal = true;
	} 

	this.formCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("FormCheckerID"))) {
		if (elem.getAttribute("FormCheckerID").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("FormCheckerID").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("name"))) {
		if (elem.getAttribute("name").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("name").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("id").toString().toLowerCase();
		}
	}

	this.required = false;
	if (parent.Functions.notNull(elem.getAttribute("Required"))) {
		if (elem.getAttribute("Required").toString().toLowerCase() == "true") {
			_obj.required = true;
		}
	}

	this.requiredErrorMessage = "is required.";
	if (parent.Functions.notNull(elem.getAttribute("RequiredErrorMessage"))) {
		if (elem.getAttribute("RequiredErrorMessage").toString().toLowerCase() != "") {
			_obj.requiredErrorMessage = elem.getAttribute("RequiredErrorMessage").toString();
		}
	}
	this.displayname = "";
	if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("id").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("Name"))) {
		if (elem.getAttribute("Name").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("Name").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("DisplayName"))) {
		if (elem.getAttribute("DisplayName").toString().toLowerCase() != "") {
			_obj.displayname = elem.getAttribute("DisplayName").toString();
		}
	}
		
	this.minNumberOfItemsSelected = 0;
	if (parent.Functions.notNull(elem.getAttribute("MinNumberOfItemsSelected"))) {
		if (elem.getAttribute("MinNumberOfItemsSelected").toString().replace(/\D+/g, "") != "") {
			_obj.minNumberOfItemsSelected = elem.getAttribute("MinNumberOfItemsSelected").toString().replace(/\D+/g, "");		
		}
	}
	this.minNumberOfItemsSelectedErrorMessage = "must have at least @MINNUMBERSELECTED chosen.";
	if (parent.Functions.notNull(elem.getAttribute("MinNumberOfItemsSelectedErrorMessage"))) {
		if (elem.getAttribute("MinNumberOfItemsSelectedErrorMessage").toString().replace(/\D+/g, "") != "") {
			_obj.minNumberOfItemsSelectedErrorMessage = elem.getAttribute("MinNumberOfItemsSelectedErrorMessage").toString().replace(/\D+/g, "");		
		}
	}

	this.maxNumberOfItemsSelected = 0;
	if (parent.Functions.notNull(elem.getAttribute("MaxNumberOfItemsSelected"))) {
		if (elem.getAttribute("MaxNumberOfItemsSelected").toString().replace(/\D+/g, "") != "") {
			_obj.maxNumberOfItemsSelected = elem.getAttribute("MaxNumberOfItemsSelected").toString().replace(/\D+/g, "");		
		}
	}
	this.maxNumberOfItemsSelectedErrorMessage = "cannot have more then @MAXNUMBERSELECTED chosen.";
	if (parent.Functions.notNull(elem.getAttribute("MaxNumberOfItemsSelectedErrorMessage"))) {
		if (elem.getAttribute("MaxNumberOfItemsSelectedErrorMessage").toString().replace(/\D+/g, "") != "") {
			_obj.maxNumberOfItemsSelectedErrorMessage = elem.getAttribute("MaxNumberOfItemsSelectedErrorMessage").toString().replace(/\D+/g, "");		
		}
	}
	
	this.creditCardTypes = "AMEX, DinnersClub, Discover, JCB, MasterCard, Visa";
	if (parent.Functions.notNull(elem.getAttribute("CreditCardTypes"))) {
		if (elem.getAttribute("CreditCardTypes").toString().toLowerCase() != "") {
			_obj.creditCardTypes = elem.getAttribute("CreditCardTypes").toString();
		}
	}
	this.creditCardTypeErrorMessage = "does not match the credit card number.";
	if (parent.Functions.notNull(elem.getAttribute("CreditCardTypeErrorMessage"))) {
		if (elem.getAttribute("CreditCardTypeErrorMessage").toString().toLowerCase() != "") {
			_obj.creditCardTypeErrorMessage = elem.getAttribute("CreditCardTypeErrorMessage").toString();
		}
	}

	this.creditcardAccountFormCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("CreditcardAccountFormCheckerID"))) {
		if (elem.getAttribute("CreditcardAccountFormCheckerID").toString().toLowerCase() != "") {
			_obj.creditcardAccountFormCheckerID = elem.getAttribute("CreditcardAccountFormCheckerID").toString().toLowerCase();
		}
	}

	
	// Methods
	this.setBackgroundColor =
		function () {
			var _option;
			
			for (var i=0;i<elem.length;i++) {
				_option = elem[i];
				_option.style.backgroundColor = _obj.errorBackgroundColor;
			}
		}

	this.clearBackgroundColor = 
		function () {
			var _option;
			
			for (var i=0;i<elem.length;i++) {
				_option = elem[i];
				_option.style.backgroundColor = "";
			}
		}
	this.focus =
		function () {
			try {
				if (elem.name.toLowerCase().indexOf("ooheader:_ctl0:_ctl0", 0) >= 0 || elem.name.toLowerCase().indexOf("_cmdbuttondropdownlistview", 0) >= 0) {
					return false;
				}
				elem.focus();
				return true;
			}
			catch(ex) {
				return false;
			}
		}
	
	this.doDisplay =
		function () {
			if (_obj.creditcardAccountFormCheckerID != "") {
				// First Remove any options that maybe there
				elem.options.length=0;
				var _arCCTypes = _obj.creditCardTypes.replace(/ /g,"").split(",");
				var _option;
				var _selectedValue ="";
				var _ccelem = parent.Functions.getFormCheckerItems(_obj.creditcardAccountFormCheckerID, parent.form);
				try {
					var _cc = new oTextBox(parent, _ccelem[0]);
					_cc.setCreditCardType();
					_selectedValue = _cc.creditcardtype;
				}
				catch(ex) {
					// do nothing the item doesn't exist
				}


				
				_option = document.createElement('option');
				_option.text = "*** Choose One ***";
				_option.value = "";
				try {
					elem.options.add(_option, null);
				}
				catch(ex) {
					elem.options.add(_option);
				}
				for (var i=0;i<_arCCTypes.length;i++) {
					_option = document.createElement('option');
					_option.text = _arCCTypes[i];
					_option.value = _arCCTypes[i];
					if (_selectedValue == _option.value) {_option.selected = true;}
					try { // Other Browser Compliant (IE6, Mac, NS, FF)
						elem.options.add(_option, null);
					}
					catch(ex) { // IE 5.5 method
						elem.options.add(_option);
					}
				}
			}
		}
	
	this.validateCardType =
		function () {
			var _ccelem = parent.Functions.getFormCheckerItems(_obj.creditcardAccountFormCheckerID, parent.form);
			var _selectedValue ="";
			try {
				var _cc = new oTextBox(parent, _ccelem[0]);
				_cc.setCreditCardType();
				_selectedValue = _cc.creditcardtype;
			}
			catch(ex) {
				// do nothing the item doesn't exist
			}
			for (var i=0;i<elem.options.length;i++) {
				if (elem.options[i].selected) {
					if (elem.options[i].value.toString().toLowerCase() != _cc.creditcardtype.toString().toLowerCase()) {
						return false;
					}
				}
			}
			return true;
		}
		
	this.validate =
		function (displayError) {
			var _option;
			var _selectcount = 0;

			var _displayErrorUI = false;
			
			if (!parent.Functions.notNull(displayError)) {
				_displayErrorUI = true;
			}
			else {
				if (displayError.toString().toLowerCase() == "true") {
					_displayErrorUI = true;
				}
			}

			if (_displayErrorUI) {_obj.setBackgroundColor();}

			if (_obj.required) {
				_selectcount = 0;
				for (var i=0;i<elem.length;i++) {
					_option = elem[i];
					if (_option.selected && _obj.selectMultipal) {
						_selectcount++;
					}
					
					if (!_obj.selectMultipal) {
						if (parent.Functions.notNull(_option.value) && _option.selected) {
							_selectcount++;
						}
					}
				}
				if (_selectcount == 0) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.requiredErrorMessage);}
					return false;
				}
			}

			if (_obj.creditcardAccountFormCheckerID != "") {
				if (!_obj.validateCardType()) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.creditCardTypeErrorMessage);}
					return false;
				}
			}

			if (_obj.selectMultipal) {
				_selectcount = 0;
				for (var i=0;i<elem.length;i++) {
					_option = elem[i];
					if (_option.selected) {
						_selectcount++;
					}
				}
				if (_selectcount < _obj.minNumberOfItemsSelected && _obj.minNumberOfItemsSelected > 0) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.minNumberOfItemsSelectedErrorMessage.replace('@MINNUMBERSELECTED',_obj.minNumberOfItemsSelected));}
					return false;
				}
				if (_selectcount > _obj.maxNumberOfItemsSelected && _obj.maxNumberOfItemsSelected > 0) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.maxNumberOfItemsSelectedErrorMessage.replace('@MAXNUMBERSELECTED',_obj.maxNumberOfItemsSelected));}
					return false;
				}
			}
			if (_displayErrorUI) {_obj.clearBackgroundColor();}
			return true;
	
		}
		
	
	// Initalization
}


function oPassword(parent, elem) {
	// Version Properties
	this.Version = new oVersion(this);

	// Objects
	var _obj = this; // Local for scope
	// Properties
	this.errorBackgroundColor = parent.errorTextBoxBackgroundColor;

	this.value = elem.value;
	this.length = elem.value.length;

	this.formCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("FormCheckerID"))) {
		if (elem.getAttribute("FormCheckerID").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("FormCheckerID").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("name"))) {
		if (elem.getAttribute("name").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("name").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("id").toString().toLowerCase();
		}
	}

	this.required = false;
	if (parent.Functions.notNull(elem.getAttribute("Required"))) {
		if (elem.getAttribute("Required").toString().toLowerCase() == "true") {
			_obj.required = true;
		}
	}
	this.requiredErrorMessage = "password is required.";
	if (parent.Functions.notNull(elem.getAttribute("RequiredErrorMessage"))) {
		if (elem.getAttribute("RequiredErrorMessage").toString().toLowerCase() != "") {
			_obj.requiredErrorMessage = elem.getAttribute("RequiredErrorMessage").toString();
		}
	}

	this.compareID = "";
	if (parent.Functions.notNull(elem.getAttribute("CompareID"))) {
		if (elem.getAttribute("CompareID").toString().toLowerCase() != "") {
			_obj.compareID = elem.getAttribute("CompareID").toString();
		}
	}
	this.passwordDifferentErrorMessage = "passwords must match.";
	if (parent.Functions.notNull(elem.getAttribute("PasswordDifferentErrorMessage"))) {
		if (elem.getAttribute("PasswordDifferentErrorMessage").toString().toLowerCase() != "") {
			_obj.passwordDifferentErrorMessage = elem.getAttribute("PasswordDifferentErrorMessage").toString();
		}
	}
	
	this.displayname = "";
	if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("id").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("Name"))) {
		if (elem.getAttribute("Name").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("Name").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("DisplayName"))) {
		if (elem.getAttribute("DisplayName").toString().toLowerCase() != "") {
			_obj.displayname = elem.getAttribute("DisplayName").toString();
		}
	}
	
	this.minLength = "0";
	if (parent.Functions.notNull(elem.getAttribute("MinLength"))) {
		if (elem.getAttribute("MinLength").toString().replace(/\D+/g, "") != "") {
			_obj.minLength = elem.getAttribute("MinLength").toString().replace(/\D+/g, "");
		}
	}
	this.minLengthErrorMessage = "must be at least " + this.minLength + " characters.";
	if (parent.Functions.notNull(elem.getAttribute("MinLengthErrorMessage"))) {
		if (elem.getAttribute("MinLengthErrorMessage").toString() != "") {
			_obj.minLengthErrorMessage = elem.getAttribute("MinLengthErrorMessage").toString();
		}
	}
	
	// Methods
	this.setBackgroundColor =
		function () {
			elem.style.backgroundColor = _obj.errorBackgroundColor;
		}

	this.clearBackgroundColor = 
		function () {
			elem.style.backgroundColor ="";
		}
	
	this.focus =
		function () {
			try {
				elem.focus();
				return true;
			}
			catch(ex) {
				return false;
			}
		}

	this.validate =
		function(displayError) {
			var _displayErrorUI = false;
			
			if (!parent.Functions.notNull(displayError)) {
				_displayErrorUI = true;
			}
			else {
				if (displayError.toString().toLowerCase() == "true") {
					_displayErrorUI = true;
				}
			}

			if (_displayErrorUI) {_obj.setBackgroundColor();}

			if (_obj.required) {
	
				if (!parent.Functions.notNull(elem.value)) {
					parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.requiredErrorMessage);
					return false;
				}
			}

			if (parseInt(_obj.minLength,10) > 0) {
				if (elem.value.length < _obj.minLength && elem.value.length > 0) {
					parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.minLengthErrorMessage); 
					return false;
				}
			}
				
			if (_obj.compareID !="" && elem.value.length > 0) {
				if (parent.Functions.notNull(elem.value)) {
					var _elem = parent.form.elements;
					for (var i=0;i<_elem.length;i++) {
						if (parent.Functions.notNull(_elem[i].getAttribute("CompareID"))) {
							if (elem.getAttribute("CompareID").toString() == _elem[i].getAttribute("CompareID").toString()) { 
								if (elem.value != _elem[i].value) {
									var insertError = true;
									for (var x=0;x<parent.arPasswordID.length;x++) {
										if (parent.arPasswordID[x] == _obj.compareID) {
											insertError = false;
										}
									}
									
									if (insertError) {
										parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.passwordDifferentErrorMessage);
										parent.arPasswordID.push(_obj.compareID);
									}
									return false;
								}
							}
						}
					}
				}
			}
			if (_displayErrorUI) {_obj.clearBackgroundColor();}
			return true;
		}


}

function oTextBox(parent, elem) {
	// Version Properties
	this.Version = new oVersion(this);

	// Objects
	var _obj = this; // Local for scope
	// Properties
	
	this.errorBackgroundColor = parent.errorTextBoxBackgroundColor;

	this.value = elem.value;
	this.length = elem.value.length;
	
	this.formCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("FormCheckerID"))) {
		if (elem.getAttribute("FormCheckerID").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("FormCheckerID").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("name"))) {
		if (elem.getAttribute("name").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("name").toString().toLowerCase();
		}
	}
	else if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() != "") {
			_obj.formCheckerID = elem.getAttribute("id").toString().toLowerCase();
		}
	}
	
	this.required = false;
	if (parent.Functions.notNull(elem.getAttribute("Required"))) {
		if (elem.getAttribute("Required").toString().toLowerCase() == "true") {
			_obj.required = true;
		}
	}
	this.requiredErrorMessage = "is required.";
	if (parent.Functions.notNull(elem.getAttribute("RequiredErrorMessage"))) {
		if (elem.getAttribute("RequiredErrorMessage").toString().toLowerCase() != "") {
			_obj.requiredErrorMessage = elem.getAttribute("RequiredErrorMessage").toString();
		}
	}
	
	this.isEmail = false;
	if (parent.Functions.notNull(elem.getAttribute("IsEmail"))) {
		if (elem.getAttribute("IsEmail").toString().toLowerCase() == "true") {
			_obj.isEmail = true;
		}
	}
	this.isEmailErrorMessage = "invalid email address.";
	if (parent.Functions.notNull(elem.getAttribute("IsEmailErrorMessage"))) {
		if (elem.getAttribute("IsEmailErrorMessage").toString().toLowerCase() != "") {
			_obj.isEmailErrorMessage = elem.getAttribute("IsEmailErrorMessage").toString();
		}
	}
	
	this.numeric = false;
	if (parent.Functions.notNull(elem.getAttribute("Numeric"))) {
		if (elem.getAttribute("Numeric").toString().toLowerCase() == "true") {
			_obj.numeric = true;
		}
	}
	
	this.numericErrorMessage = "is not a valid number.";
	if (parent.Functions.notNull(elem.getAttribute("NumericErrorMessage"))) {
		if (elem.getAttribute("NumericErrorMessage").toString().toLowerCase() != "") {
			_obj.numericErrorMessage = elem.getAttribute("NumericErrorMessage").toString();
		}
	}
	
	this.numericmask = "";
	if (parent.Functions.notNull(elem.getAttribute("Numericmask"))) {
		if (elem.getAttribute("Numericmask").toString().toLowerCase() != "") {
			_obj.numericmask = elem.getAttribute("Numericmask").toString();
		}
	}
	this.numericmaskErrorMessage = "is not the proper length.";
	if (parent.Functions.notNull(elem.getAttribute("NumericmaskErrorMessage"))) {
		if (elem.getAttribute("NumericmaskErrorMessage").toString().toLowerCase() != "") {
			_obj.numericmaskErrorMessage = elem.getAttribute("NumericmaskErrorMessage").toString();
		}
	}

	this.minLength = "0";
	if (parent.Functions.notNull(elem.getAttribute("MinLength"))) {
		if (elem.getAttribute("MinLength").toString().replace(/\D+/g, "") != "") {
			_obj.minLength = elem.getAttribute("MinLength").toString().replace(/\D+/g, "");
		}
	}
	this.minLengthErrorMessage = "must be at least " + this.minLength + " characters.";
	if (parent.Functions.notNull(elem.getAttribute("MinLengthErrorMessage"))) {
		if (elem.getAttribute("minLengthErrorMessage").toString() != "") {
			_obj.minLengthErrorMessage = elem.getAttribute("MinLengthErrorMessage").toString();
		}
	}

	this.isDecimal = false;
	if (parent.Functions.notNull(elem.getAttribute("IsDecimal"))) {
		if (elem.getAttribute("IsDecimal").toString().toLowerCase() == "true") {
			_obj.isDecimal = true;
			if (_obj.numericmask == "") {
				// Default numeric mask
				_obj.numericmask = ".##";
				// isDecimal does not obey length rules, use compareMinValue and compareMaxValue
				_obj.minLength = 0;
			}
		}
	}


	this.isUSPhone = false;
	if (parent.Functions.notNull(elem.getAttribute("IsUSPhone"))) {
		if (elem.getAttribute("IsUSPhone").toString().toLowerCase() == "true") {
			_obj.isUSPhone = true;
			if (_obj.numericmask == "" || parent.Functions.replaceAll(_obj.numericmask, [["#", "1"]] ).replace(/\D+/g, "").length != 10) {
				_obj.numericmask = "(###) ###-####";
				_obj.minLength = 0;
			}
		}
	}
	
	this.isUSPhoneErrorMessage = "is not a valid US Phone Number.";
	if (_obj.isUSPhone) {
		_obj.numericmaskErrorMessage = _obj.isUSPhoneErrorMessage;
	}
	if (parent.Functions.notNull(elem.getAttribute("IsUSPhoneErrorMessage"))) {
		if (elem.getAttribute("IsUSPhoneErrorMessage").toString().toLowerCase() != "") {
			// Use of numeric mask is BY DESIGN
			_obj.numericmaskErrorMessage = elem.getAttribute("IsUSPhoneErrorMessage").toString();
		}
	}

	this.compareMinValue = "";
	if (parent.Functions.notNull(elem.getAttribute("CompareMinValue"))) {
		if (elem.getAttribute("CompareMinValue").toString().toLowerCase() != "") {
			_obj.compareMinValue = elem.getAttribute("CompareMinValue").toString();
		}
	}
	this.compareMinValueErrorMessage = "(@VALUEOF) is less then minimum of @MINRATE.";
	if (parent.Functions.notNull(elem.getAttribute("CompareMinValueErrorMessage"))) {
		if (elem.getAttribute("CompareMinValueErrorMessage").toString().toLowerCase() != "") {
			_obj.compareMinValueErrorMessage = elem.getAttribute("CompareMinValueErrorMessage").toString();
		}
	}

	this.compareMaxValue = "";
	if (parent.Functions.notNull(elem.getAttribute("CompareMaxValue"))) {
		if (elem.getAttribute("CompareMaxValue").toString().toLowerCase() != "") {
			_obj.compareMaxValue = elem.getAttribute("CompareMaxValue").toString();
		}
	}
	this.compareMaxValueErrorMessage = "(@VALUEOF) exceeds the maximum of @MAXRATE.";
	if (parent.Functions.notNull(elem.getAttribute("CompareMaxValueErrorMessage"))) {
		if (elem.getAttribute("CompareMaxValueErrorMessage").toString().toLowerCase() != "") {
			_obj.compareMaxValueErrorMessage = elem.getAttribute("CompareMaxValueErrorMessage").toString();
		}
	}
	
	
		
	this.compareID = "";
	if (parent.Functions.notNull(elem.getAttribute("CompareID"))) {
		if (elem.getAttribute("CompareID").toString().toLowerCase() != "") {
			_obj.compareID = elem.getAttribute("CompareID").toString();
		}
	}
	
	this.compareDifferentErrorMessage = "does not match.";
	if (parent.Functions.notNull(elem.getAttribute("CompareDifferentErrorMessage"))) {
		if (elem.getAttribute("CompareDifferentErrorMessage").toString().toLowerCase() != "") {
			_obj.compareDifferentErrorMessage = elem.getAttribute("CompareDifferentErrorMessage").toString();
		}
	}
	this.creditcardtype = "";
	if (parent.Functions.notNull(elem.getAttribute("CreditCardType"))) {
		if (elem.getAttribute("CreditCardType").toString().toLowerCase() != "") {
			_obj.creditcardtype = elem.getAttribute("CreditCardType").toString().toLowerCase();
		}
	}
	this.creditcard = false;
	if (parent.Functions.notNull(elem.getAttribute("CreditCard"))) {
		if (elem.getAttribute("CreditCard").toString().toLowerCase() == "true") {
			_obj.creditcard = true;
			if (_obj.numericmask == "") {
				_obj.numericmask = "####-####-####-####";
				_obj.numeric = true;
				_obj.minLength = 13;
			}
		}
	}

	this.creditCardNumberErrorMessage = "is not a valid credit card number.";
	if (parent.Functions.notNull(elem.getAttribute("CreditCardNumberErrorMessage"))) {
		if (elem.getAttribute("CreditCardNumberErrorMessage").toString().toLowerCase() != "") {
			_obj.creditCardNumberErrorMessage = elem.getAttribute("CreditCardNumberErrorMessage").toString();
		}
	}

	// FormCheckerID of a dependent entity.
	// By indicating a dependency, this field becomes required
	// if length of another textbox > 0
	this.dependsOnFormCheckerID = "";
	if (parent.Functions.notNull(elem.getAttribute("dependsOnFormCheckerID"))) {
		if (elem.getAttribute("dependsOnFormCheckerID").toString().toLowerCase() != "") {
			_obj.dependsOnFormCheckerID = elem.getAttribute("dependsOnFormCheckerID").toString();
		}
	}
	
	this.dependsOnCheckBoxChecked = false;
	if (parent.Functions.notNull(elem.getAttribute("DependsOnCheckBoxChecked"))) {
		if (elem.getAttribute("DependsOnCheckBoxChecked").toString().toLowerCase() != "true") {
			_obj.dependsOnCheckBoxChecked = true;
		}
	}
	
	this.displayname = "";
	if (parent.Functions.notNull(elem.getAttribute("id"))) {
		if (elem.getAttribute("id").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("id").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("Name"))) {
		if (elem.getAttribute("Name").toString().toLowerCase() !== "") {
			_obj.displayname = elem.getAttribute("Name").toString();
		}
	}
	if (parent.Functions.notNull(elem.getAttribute("DisplayName"))) {
		if (elem.getAttribute("DisplayName").toString().toLowerCase() != "") {
			_obj.displayname = elem.getAttribute("DisplayName").toString();
		}
	}
	
	
	// Methods
	this.setBackgroundColor =
		function () {
			elem.style.backgroundColor = _obj.errorBackgroundColor;
		}

	this.clearBackgroundColor = 
		function () {
			elem.style.backgroundColor ="";
		}
	this.focus =
		function () {
			try {
				elem.focus();
				return true;
			}
			catch(ex) {
				return false;
			}
		}
	this.displayMask = 
		function () {
			var retVal = _obj.numericmask; 

			for(var i=0;i<elem.value.length;i++) {

				retVal = retVal.replace(/#/i, elem.value.charAt(i));

			}

			// get rid of rest of #'s

			retVal = retVal.replace(/#/gi, "");
			elem.value = retVal;
		}
		
			
			

	this.doDisplay =
		function () {
			var obj = _obj;
			var _decimalplaces=2; // Default
			var _moneyprefix="";
			var _minLength = parseInt(obj.minLength, 10);
			var _mask = obj.numericmask;
			var _premask = obj.numericmask;
			if (elem.value.length > 0 && obj.numericmask != "") {
				if (obj.creditcard) {
					obj.setCreditCardType();
				}
				if (obj.isUSPhone) {
					if (elem.value.substring(0,1) == "1") {
						elem.value = elem.value.substring(1,elem.value.length)		
					}
					elem.value = elem.value.replace(/\D+/g, "");
					obj.displayMask();
					return;
				}
				if (obj.isDecimal) {
					// get the mask and find the period (assume . somewhere in the field else they woudl use numeric only
					if (_mask.substring(0,1) == "$") {_moneyprefix="$"}
					if (_mask.substring(0,1) == "¢") {_moneyprefix="¢"}
					_decimalplaces = obj.numericmask.split(".")[obj.numericmask.split(".").length-1].length;
					_lenghtbeforedecimal = (elem.value.replace(/\D+/g, "").length)-_decimalplaces;
					_maskbeforedecimal = obj.numericmask.split(".")[obj.numericmask.split(".").length-2];
					_mask = "";
					
					for (var x=0;x<_decimalplaces;x++) {
						_mask = "#" + _mask;
					}
					_mask = "." + _mask;
					for (var y=0;y<_lenghtbeforedecimal;y++) {
						_mask = "#" + _mask;
					}
					
					_mask = _moneyprefix + _mask;
					obj.numericmask = _mask;
					
					if (_minLength <= elem.value.length) {
						elem.value = elem.value.replace(/\D+/g, "");
						obj.displayMask();
						obj.numericmask = _premask;
						return;
					}
				}
				if (_minLength !=0) {
					if (_minLength < parent.Functions.replaceAll(_obj.numericmask, [["#", "1"]] ).replace(/\D+/g, "").length) {
						_minLength = parent.Functions.replaceAll(_obj.numericmask, [["#", "1"]] ).replace(/\D+/g, "").length;
					}
					if (obj.numericmask !="" && elem.value.length > 0) {
						if (_minLength >= elem.value.length) {
							elem.value = elem.value.replace(/\D+/g, "");
							obj.displayMask();
							return;
						}
					}
				}
				if (_minLength==0) {
					elem.value = elem.value.replace(/\D+/g, "");
					obj.displayMask();
					return;
				}
				
				
			}
		}		

	this.setEventsForNumericMask = 
		function (){
			if (_obj.numericmask !="") {
				var _doDisplay = _obj.doDisplay;
				var _onblur = elem.onblur;
				var _onfocus = elem.onfocus;
				var _onkeyup = elem.onkeyup;
				var _onfocus = elem.onfocus;
				
				elem.onblur = 
					function () {
						_obj.doDisplay();
						if (typeof _onblur == 'function') { _onblur();}
					}
						
				elem.onfocus = 
					function () {
						_obj.doDisplay();
						elem.select();
						if (typeof _onfocus == 'function') { _onfocus();}
						elem.onkeyup=
							function () {
								var elem=this;
								elem.onkeyup=
									function () {
										if (typeof _onkeyup == 'function') { _onkeyup();}
										_doDisplay();
									}
							}
					}
			}
		}
	
	this.setCreditCardType =
		function () {
			var ccLength = elem.value.replace(/\D+/g,"").length;
			switch (elem.value.replace(/\D+/g, "").substring(0, 2).toString()) {
				case "37":
					if (ccLength == 15) {
						_obj.creditcardtype = "AMEX";
					}
				break;
				case "35":
					if (ccLength == 16) {
						_obj.creditcardtype = "JCB";
					}
				break;
				case "38":
					if (ccLength == 14) {
						_obj.creditcardtype = "DinnersClub";
					}
				break;
				case "30":
					if (ccLength == 14) {
						_obj.creditcardtype = "DinnersClub";
					}
				break;				
				default:
					switch (elem.value.replace(/\D+/g, "").substring(0, 1).toString()) {
						case "3":
							if (ccLength == 15) {
								_obj.creditcardtype = "AMEX";
							}
						break;
						case "4":
							if (ccLength == 13 || ccLength == 16) {
								_obj.creditcardtype = "Visa";
							}
						break;
						case "5":
							if (ccLength == 16) {
								_obj.creditcardtype = "MasterCard";
							}
						break;
						case "6":
							if (ccLength == 16) {
								_obj.creditcardtype = "Discover";
							}
						break;
						default:
							_obj.creditcardtype = "";
						break;
					}
				break;
			}
			if (_obj.creditcardtype != "") {
				elem.setAttribute("creditcardtype", _obj.creditcardtype); 
			}
		}
		
	this.checkCreditCardNumber =
		function () {
			var _ccnumber = elem.value.replace(/D+/g,"");
			var _intTotal = 0;
			var _intTmp = 0;
			_ccnumber = _ccnumber.replace(/\D+/g, "");
			for (var i = 0; i < _ccnumber.length; i++) {
				var j = 0;
				_intTmp = _ccnumber.substring(_ccnumber.length - i - 1, _ccnumber.length - i);
				if (((i) % 2) != 0) {
					_intTmp = _ccnumber.substring(_ccnumber.length - i - 1, _ccnumber.length - i) * 2;
					if (_intTmp >= 10) { _intTmp = (_intTmp - 10) + 1; }
				}
				_intTotal = (_intTotal - 0) + (_intTmp - 0);
			}
			if (_intTotal % 10 != 0) { return false; }
			return true;
		}
	
	this.dependency =
		function (dependsOnFormCheckerID) {
			var elem = parent.Functions.getFormCheckerItems(dependsOnFormCheckerID,parent.form)
			for (var i=0;i<elem.length;i++) {
				switch (elem[i].type) {
					case "text":
						// text type validations
						var _textbox = new oTextBox(parent, elem[i]);
						if (_textbox.length > 0) {
							_obj.required = true;
							if (!_textbox.validate(false)) {
								return false;
							}
						}
					break;
					case "select-multiple":
						// select-multiple validations
					break;
					case "select-one":
						// select-one validations
					break;
					case "password":
						// password validations
						var _password = new oPassword(parent, elem[i]);
						if (_password.length > 0) {
							_obj.required = true;
							if (!_password.validate(false)) {
								return false;
							}
						}
					break;
					case "checkbox":
						// checkbox validations
						var _checkbox = new oCheckbox(parent, elem[i]);
						// first check requirements
						// if its not required, insure its checked or not checked by property.
						if (_obj.dependsOnCheckBoxChecked == true && !_checkbox.checked) {
							_obj.required = true;
							_checkbox.required = true;
							if (!_checkbox.validate(false)) {
								return false;
							}
						}
						else if (_obj.dependsOnCheckBoxChecked == false && _checkbox.checked) {
							_obj.required = true;
							_checkbox.required = false;
							if (!_checkbox.validate(false)) {
								return false;
							}
						}

						
					break;
					case "textarea":
						// textarea validations
					break;
					case "file":
						// file validations
					break;
					case "radio":
						// radio validations
					break;
					default:
					break;
				}
			}
			return true;
		}
			
	this.validate =
		function(displayError) {
			var _displayErrorUI = false;
			
			if (!parent.Functions.notNull(displayError)) {
				_displayErrorUI = true;
			}
			else {
				if (displayError.toString().toLowerCase() == "true") {
					_displayErrorUI = true;
				}
			}

			if (_displayErrorUI) {_obj.setBackgroundColor();}

			if (_obj.dependsOnFormCheckerID != "") {
				_obj.dependency(_obj.dependsOnFormCheckerID);
			}

			if (_obj.required) {
				if (!parent.Functions.notNull(elem.value)) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.requiredErrorMessage);}
					return false;
				}
			}
			if (_obj.isEmail) {
				if (elem.value.match(/^((([a-zA-Z0-9-_]*)([.]{0,1})){1,9})(@{1,1})(([a-zA-Z0-9-]*[.]{1,1}){1,9})(\w{2,3})$/) == null) { 
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.isEmailErrorMessage);}
					return false;
				}
			}
			if (_obj.isUSPhone) {
				if (elem.value.substring(0,1) == "1") {
					elem.value = elem.value.substring(1,elem.value.length)		
				}
				if (_obj.numericmask == "" || parent.Functions.replaceAll(_obj.numericmask, [["#", "1"]] ).replace(/\D+/g, "").length != 10) {
					_obj.numericmask = "(###) ###-####";
					_obj.minLength = 0;
					_obj.numeric = true;
				}
			}
			if (_obj.creditcard) {
				_obj.setCreditCardType();
				if (!_obj.checkCreditCardNumber()) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.creditCardNumberErrorMessage);}
					return false;
				}
			}
			if (_obj.numeric && elem.value.length > 0) {
				elem.value = elem.value.replace(/\D+/g, "");
				if (parseInt(elem.value, 10) == 0 || isNaN(parseInt(elem.value, 10))) { 
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.numericErrorMessage);}
					return false;
				}
			}

			if (parseInt(_obj.minLength,10) > 0) {
				if (elem.value.length < _obj.minLength && elem.value.length > 0) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.minLengthErrorMessage);}
					return false;
				}
			}
			
			if (_obj.compareMinValue !="" && elem.value.length > 0) {
				if (_obj.numeric) {
					if(parseInt(elem.value.replace(/\D+/g, ""),10) < parseInt(_obj.compareMinValue.replace(/\D+/g, ""),10)) {
						if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.compareMinValueErrorMessage.replace('@VALUEOF', elem.value).replace('@MINRATE', _obj.compareMinValue.replace(/\D+/g, ""))); }
						return false;
					}
				}
				if (_obj.numericmask !="") {
					if(parseInt(elem.value.replace(/\D+/g, ""),10) < parseInt(_obj.compareMinValue.replace(/\D+/g, ""),10)) {
						if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.compareMinValueErrorMessage.replace('@VALUEOF', elem.value).replace('@MINRATE', _obj.compareMinValue));}
						return false;
					}
				}
				if(elem.value < _obj.compareMinValue && !(_obj.numeric || _obj.numericmask != "")) {
						if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.compareMinValueErrorMessage.replace('@VALUEOF', elem.value).replace('@MINRATE', _obj.compareMinValue));}
						return false;
				}
			}
			
			if (_obj.compareMaxValue !="" && elem.value.length > 0) {
				if (_obj.numeric) {
					if(parseInt(elem.value.replace(/\D+/g, ""),10) > parseInt(_obj.compareMaxValue.replace(/\D+/g, ""),10)) {
						if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.compareMaxValueErrorMessage.replace('@VALUEOF', elem.value).replace('@MAXRATE', _obj.compareMaxValue.replace(/\D+/g, ""))); }
						return false;
					}
				}
				if (_obj.numericmask !="") {
					if(parseInt(elem.value.replace(/\D+/g, ""),10) > parseInt(_obj.compareMaxValue.replace(/\D+/g, ""),10)) {
						if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.compareMaxValueErrorMessage.replace('@VALUEOF', elem.value).replace('@MAXRATE', _obj.compareMaxValue));}
						return false;
					}
				}
				if(elem.value > _obj.compareMaxValue && !(_obj.numeric || _obj.numericmask != "")) {
					if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.compareMaxValueErrorMessage.replace('@VALUEOF', elem.value).replace('@MAXRATE', _obj.compareMaxValue)); }
					return false;
				}
			}
			
			if ((_obj.numericmask !="" && elem.value.length > 0)  && (!_obj.isDecimal)) {
				if (parseInt(_obj.minLength,10) == 0) {
					if (elem.value.replace(/\D+/g, "").length != parent.Functions.replaceAll(_obj.numericmask, [["#", "1"]] ).replace(/\D+/g, "").length) {
						if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.numericmaskErrorMessage); }
						return false;
					}
				} else {
					if (elem.value.replace(/\D+/g, "").length != parent.Functions.replaceAll(_obj.numericmask, [["#", "1"]] ).replace(/\D+/g, "").length ) {
						if (elem.value.replace(/\D+/g, "").length < parseInt(_obj.minLength,10)) {
							if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.numericmaskErrorMessage); }
							return false;
						}
					}
				}
			}

			if (_obj.compareID !="" && elem.value.length > 0) {
				if (parent.Functions.notNull(elem.value)) {
					var _elem = parent.form.elements;
					for (var i=0;i<_elem.length;i++) {
						if (parent.Functions.notNull(_elem[i].getAttribute("CompareID"))) {
							if (elem.getAttribute("CompareID").toString() == _elem[i].getAttribute("CompareID").toString()) { 
								if (elem.value != _elem[i].value) {
									var insertError = true;
									for (var x=0;x<parent.arCompareID.length;x++) {
										if (parent.arCompareID[x] == _obj.compareID) {
											insertError = false;
										}
									}
									
									if (insertError) {
										if (_displayErrorUI) {parent.Messages.appendMessage(_obj.displayname + ' ' + _obj.compareDifferentErrorMessage);}
										parent.arCompareID.push(_obj.compareID)
									}
									return false;
								}
							}
						}
					}
					return false;
				}
				
			}
			

			if (_displayErrorUI) {_obj.clearBackgroundColor();}

			
			return true;
				
		}
	
	// Initialization
}

function oMessages(parent) {
	// Version Properties
	this.Version = new oVersion(this);

	// Objects
	var _obj = this; // Local for scope
	// Properties
	this.name = "oMessages";
	this.message = "";
	this.messagetitle = "There are errors in your request.\nPlease correct the following errors and try again.\n______________________________________\n\n";

	// Methods
	this.appendMessage =
		function (str) {
			_obj.message = _obj.message + str + "\n";
		}
	this.displayMessage = 
		function() {
			alert(_obj.messagetitle+_obj.message);
		}

	// Initialization

}

// oFunctions must be built on another object
function oFunctions(parent) {
	// Version Properties
	this.Version = new oVersion(this);
	// Objects
	var _obj = this; // Local for scope
	// Properties
	this.name = "oFunctions";
	// Methods
	// notNull returns TRUE if the value supplied is not null or blank.
	this.notNull = 
		function(str) {
			if ((str == null ) ||str.toString().replace(/\s+/g, "") == "" || str.toString().replace(/\s+/g, "") == null) {
				return false;
			}
			return true;
		}

	// Replace all instances of an item.
	this.replaceAll =
		function ( str, replacements ) {
			for (var i = 0; i < replacements.length; i++ ) {
				var idx = str.indexOf( replacements[i][0] );

				while ( idx > -1 ) {
					str = str.replace( replacements[i][0], replacements[i][1] ); 
					idx = str.indexOf( replacements[i][0] );
				}

			}

			return str;
		}
	// Reverse a string
	this.reverseString =
		function (str) {
			var retVal="";
			for (var i = 0;i<str.length;i++) {
				retVal = str.charAt(i) + retVal;
			}
			return retVal;
		}
	
	this.getFormCheckerItems = 
		function (formCheckerID, doc) {
			var elems = new Array();
			var _elements = doc.elements;
		
			
			// First Try to find the elements using our custom tag
			for (var i = 0;i<_elements.length;i++) {
				if (this.notNull(_elements[i].getAttribute("FormCheckerID")) && this.notNull(formCheckerID)) {
					if (_elements[i].getAttribute("FormCheckerID").toString().toLowerCase() == formCheckerID.toLowerCase()) {
						elems.push(_elements[i]);
					}
				}
			}
			if (elems.length == 0) {
				// None found, maybe they ment the "name" attribute
				for (var i = 0;i<_elements.length;i++) {
					if (this.notNull(_elements[i].getAttribute("name")) && this.notNull(formCheckerID)) {
						if (_elements[i].getAttribute("name").toString().toLowerCase() == formCheckerID.toLowerCase()) {
							elems.push(_elements[i]);
						}
					}
				}
			}
			
			if (elems.length == 0) {
				// None still found, last chance hopefully it is the "ID"
				for (var i = 0;i<_elements.length;i++) {
					if (this.notNull(_elements[i].getAttribute("id")) && this.notNull(formCheckerID)) {
						if (_elements[i].getAttribute("id").toString().toLowerCase() == formCheckerID.toLowerCase()) {
							elems.push(_elements[i]);
						}
					}
				}
			}
			return elems;
		}
	this.addloadEvent = 
		function (func) {
			var oldonload = window.onload; 
			if (typeof window.onload != 'function') { 
				window.onload = func; 
			} else { 
				window.onload = function() { 
					oldonload(); 
					func(); 
				} 
			} 
		 }

	this.addsubmitEvent = 
		function (doc, func) {
			var oldonsubmit = doc.onsubmit; 
			if (typeof doc.onsubmit != 'function') { 
				doc.onsubmit = function () {
					return func(this); 
				}
			} else { 
				doc.onsubmit = function() { 
					if (func(this)) { 
						return oldonsubmit();
					}
					return false;
				}
			}
		 }
	
	// Initalization
}

function oVersion(parent) {
	// Properties - Only item here for versioning information
	this.name = "FormChecker";
	this.version = "2.01";
	this.versiondate = "June 1, 2005";
	parent.version = this.version;
	parent.versiondate = this.versiondate;

}

function oEnums(parent) {
	this.name = "oEnums"
	this.dependsOnFormCheckerID = "dependsOnFormCheckerID";
	this.FormCheckerID = "FormCheckerID";
}

var Validation = new oValidation();



