<!-- hide -->
/* Javascript Application: Form Validator
** File Name: validate.js
** Version: 6.0
**/
var winShowErrors;
var strStyleSheet;
var strErrorWindowOutput = '';
var strSpecialFunction = '';

/* try this with the tag name property to test for form vs.element.*/

strStyleSheet = '/Styles/style.css';

/*'**************************************************************************
'* Program:	validateMTabForm
'*
'* Created By/Date:	Michael Howard - 1/13/2003
'*
'* Purpose: To perform standard validation checks on a form that includes
'*					hidden tabs.
'*
'* Return Value:		boolean - true if validation is passed, false otherwise 
'*
'* Input Parameters:
'*
'*		theForm - string identifying the name attribute assigned
'*									 to the radio buttons in question
'*
'*		blnImmediateOutput - boolean indicating if error dialog should be
'*												 immediately displayed or if DisplayErrors
'*												 will be explicitly called later to allow for
'*												 custom validation.
'*
'*	Notes:
'*		This function is merely a copy of the standard 'validateForm' function
'*		modified to have the error dialog display the appropriate tab before
'*		attempting to set focus on the element to which the error is related.
'*		This was done to avoid modifying '\systemMsg\errorReport.asp'.  If
'*		this manner of implementing tabs is adopted by additional developers,
'*		modifying 'errorReport.asp' might be considered.
'*****************************************************************************/
function validateMTabForm(theForm, blnImmediateOutput)
{
	var arrFormElements = theForm.elements; 
	var blnIsValid, blnIsValidTemp;
	var intCounter;
	
	
	if (arguments.length == 1)
	{
		blnImmediateOutput = true;
	}

	blnIsValid = true;
	
	strErrorWindowOutput = '';
	
	for (intCounter = 0; intCounter < arrFormElements.length; intCounter++)
	{
		blnIsValidTemp = validateElementSilent(arrFormElements[intCounter], false, false);

		if (!blnIsValidTemp)
		{
			AddError(arrFormElements[intCounter], strTabFormGoToErrorFunction(arrFormElements[intCounter].id));
		}
		
		blnIsValid = blnIsValid && blnIsValidTemp;
	}

	// Check if we are returning this immediately
	if (blnImmediateOutput)
	{
		// OK. We want to display now, so check if there were errors
		if (strErrorWindowOutput != '')
		{
			// There were errors, so call showErrors
			DisplayErrors();
		}
	}
	return blnIsValid;

}//end function validateMTabForm

/*'**************************************************************************
'* Program:	strTabFormGoToErrorFunction
'*
'* Created By/Date:	Michael Howard - 1/13/2003
'*
'* Purpose: Returns text of function passed to AddError function when using
'*					a tabbed form.  This block of code activates the appropriate tab
'*					before attempting to set focus on the error element
'*
'* Return Value:		String 
'*
'* Input Parameters:  strElementID - string identifying the element to which
'*																	 the error relates
'*
'* Note:		This code	assumes that the tab row (TR) identifies its
'*					corresponding tab	label (TD) with a non-standard attribute of
'*					'tablabelid'.
'*
'*****************************************************************************/
function strTabFormGoToErrorFunction(strElementID) {

	return	'var objGoTo = dialogArguments.document.getElementById(\'' + strElementID + '\'); ' +
					'var objTabSearch = objGoTo.parentElement; ' +
					'while (objTabSearch.tagName != \'BODY\') {' +
						'var strTabLabelID = cbAttribute(objTabSearch, \'tablabelid\'); ' +
						'if (strTabLabelID != null) { ' +
							'dialogArguments.document.getElementById(strTabLabelID).click(); ' +
						'} ' +
						'objTabSearch = objTabSearch.parentElement; ' +
					'} ' +
					'objGoTo.focus(); ' +
					'window.close();';

}//end function strTabFormGoToErrorFunction

/*******************************************************************************
** Pattern and Message Library
*******************************************************************************/
var objPatternsDict = new Object();
var objPatternsMsg = new Object();

//objPatternsDict.AlphaNum = /^\w|\s+$/i;
objPatternsDict.AlphaNum = /^[\w\W]+$/i;
objPatternsMsg.AlphaNum = 'This field must contain alphanumeric data.&nbsp;&nbsp;Example:  &quot;75th Cavalry&quot;';

///<(.*)>.*<\/\1>/
objPatternsDict.AlphaNumNoHTML = /^[a-zA-Z0-9_]*[^<]*[a-zA-Z0-9_]*[^>]*[a-zA-Z0-9_]*$/
objPatternsMsg.AlphaNumNoHTML = 'This field must contain alphanumeric data.&nbsp;&nbsp;HTML tags are not permitted.&nbsp;&nbsp;Example:  &quot;75th Cavalry&quot;';

objPatternsDict.AreaCode = /^\d{3}$/;
objPatternsMsg.AreaCode = 'This area code field must contain three digit numeric data only.&nbsp;&nbsp;Example:  &quot;512&quot;';

objPatternsDict.Blank = /\w+/i;
objPatternsMsg.Blank = '';

//objPatternsDict.Currency = /^\d{0,3}(\d{3})*\.\d{2}$/;
// ^(([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{2}))?|([1-9]{1}[0-9]{0,}(\.[0-9]{2}))?|(0(\.[0-9]{2}))?|((\.[0-9]{2}))?)$
objPatternsDict.Currency = /^(([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{2}))?|([1-9]{1}[0-9]{0,}(\.[0-9]{2}))?|(0(\.[0-9]{2}))?|((\.[0-9]{2}))?)$/;
objPatternsMsg.Currency = 'This currency field may contain numeric data ending with two decimal places.&nbsp;&nbsp;Example:  &quot;1,900.00&quot; or &quot;9,030,050.25&quot;';

objPatternsDict.Decimal = /^[-+]?\d+(\.\d+)?$/;
objPatternsMsg.Decimal = 'This decimal field may contain numeric data ending with zero or more decimal places.&nbsp;&nbsp;Example:  &quot;4.0&quot; or &quot;1234.5678&quot;';

objPatternsDict.GPA = /^\d{1,2}(\.\d*)?$/;
objPatternsMsg.GPA = 'This G.P.A. field may contain numeric data with as many as two digits to the left and two digits to the right of a decimal point.&nbsp;&nbsp;Example:  &quot;4.0&quot; or &quot;12.34&quot; or &quot;4&quot;';  

objPatternsDict.Duration = /^\d*$/;
objPatternsMsg.Duration = 'This field must contain a duration.&nbsp;&nbsp;Example:  &quot;1 hr., 15 mins.&quot;';

objPatternsDict.LowerCase = /[a-z]/;
objPatternsMsg.LowerCase = 'This field must contain some lower case text.&nbsp;&nbsp;Example:  &quot;Lower Case&quot;';

objPatternsDict.UpperCase = /[A-Z]/;
objPatternsMsg.UpperCase = 'This field must contain some upper case text.&nbsp;&nbsp;Example:  &quot;Upper Case&quot;';

objPatternsDict.LowerUpperCase = /[a-zA-Z]/;
objPatternsMsg.LowerUpperCase = 'This field must contain lower or upper case text.&nbsp;&nbsp;Example:  &quot;Mixed Case&quot;';

objPatternsDict.Number = /\d/;
objPatternsMsg.Number = 'This field must contain a number.&nbsp;&nbsp;Example:  &quot;Number 1&quot;';

objPatternsDict.StrictPassword = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,25}$/;
objPatternsMsg.StrictPassword = 'This password field must contain a valid password.  A valid password must contain one or more letters and one or more numbers.&nbsp; A valid password can not contain your first or last name.&nbsp;&nbsp;Example: &quot;Password1&quot;';

objPatternsDict.Date10 = /^\d{2}[/]\d{2}[/]\d{4}$/;
objPatternsMsg.Date10 = 'This date field must contain an 10-digit date formatted as in the example.&nbsp;&nbsp;Example:  &quot;01/05/1999&quot;';

objPatternsDict.Date8 = /^\d{2}[/]\d{2}[/]\d{2}$/;
objPatternsMsg.Date8 = 'This date field must contain an 8-digit date formatted as in the example.&nbsp;&nbsp;Example:  &quot;01/05/99&quot;';

objPatternsDict.DateBoth = /^\d{1,}[/|-]\d{1,}[/|-](\d{2}|\d{4})$/;
objPatternsMsg.DateBoth = 'This date field must contain either an 8- or 10-digit date formatted as in the example.&nbsp;&nbsp;Example:  &quot;01/05/1999&quot; or &quot;1/5/99&quot; or &quot;01-05-1999&quot; or &quot;1-5-99&quot;';

objPatternsDict.Date = /^\d{1,}[/|-]\d{1,}[/|-](\d{2}|\d{4})$/;
objPatternsMsg.Date = 'This date field must contain either an 8- or 10-digit date formatted as in the example.&nbsp;&nbsp;Example:  &quot;01/05/1999&quot; or &quot;1/5/99&quot; or &quot;01-05-1999&quot; or &quot;1-5-99&quot;';

objPatternsDict.QuarterlyDate = /^\d{1,}[/|-]\d{1,}[/|-](\d{2}|\d{4})$/;
objPatternsMsg.QuarterlyDate = '<B><FONT color=red>This date must fall on the first day of a quarter.</FONT></B> This date field must contain either an 8- or 10-digit date formatted as in the example.&nbsp;&nbsp;Example:  &quot;01/01/1999&quot; or &quot;1/1/99&quot; or &quot;01-01-1999&quot; or &quot;1-1-99&quot;';

//objPatternsDict.Email = /^[a-z0-9_.]{2,}[@][a-z0-9_.]{2,}[.][a-z0-9]{2,}$/i;
objPatternsDict.Email = /^[a-z0-9_.\-]{2,}[@][a-z0-9_.\-]{2,}[.][a-z0-9]{2,}$/i;
objPatternsMsg.Email = 'This e-mail field must contain an address of at least 2 characters, a domain name of at least 2 characters and a domain suffix of at least 2 characters.  This field may also contain numerous sub-domains.&nbsp;&nbsp;Example:  &quot;user@website.com&quot; or &quot;first_last@city.state.us&quot; or &quot;first.last@unit.army.mil&quot;';

objPatternsDict.Numeric = /^\d*$/;
objPatternsMsg.Numeric = 'This numeric field must contain whole numbers only.&nbsp;&nbsp;Negative numbers are not allowed.&nbsp;&nbsp;Example:  &quot;250&quot;';

objPatternsDict.Percentage = /^\d*$/;
objPatternsMsg.Percentage = 'This percentage field must contain whole numbers only between 0 and 100.&nbsp;&nbsp;Example:  &quot;50&quot;';

//objPatternsDict.DropDown = /^[-]\d*$/;
objPatternsDict.DropDown = /^[a-zA-Z0-9\s.\-\{\}]+$/;
objPatternsMsg.DropDown = 'This drop down field must have a valid selection.';

objPatternsDict.Required = /./;
objPatternsMsg.Required = 'This field is required and may not be left blank.';

objPatternsDict.Telephone = /^([(]?\d{3}([)]|[-]))?\d{3}[-]\d{4}([x]\d{1,6})?$/;
objPatternsMsg.Telephone = '<br>This telephone number field must contain telephone number data only.  The area code is optional and the extension may be 1 to 6 digits long. Do not enter a space before the extension.<br><br><b>Examples</b><br>728-3500<br>728-3500x000000<br>(512)728-3500<br>(512)728-3500x000000';

objPatternsDict.Text = /^\D+[^\d]$/;
objPatternsMsg.Text = 'This text field must contain non-numeric data only.&nbsp;&nbsp;Example:  &quot;The quick brown fox.&quot;';

objPatternsDict.Time24 = /^\d{2}:\d{2}$/;
objPatternsMsg.Time24 = 'This time field may contain the time in 24-hour format.&nbsp;&nbsp;Example:  &quot;12:45&quot; or &quot;18:38&quot;';

objPatternsDict.Time12 = /^([0-1][0-9]|[2][0-3]):([0-5][0-9])\s[P,A][M]$/;
objPatternsMsg.Time12 = 'This time field may contain the time in 12-hour format.&nbsp;&nbsp;Example:  &quot;12:45&nbsp;PM&quot;';

objPatternsDict.Time = /^([0-1][0-9]|[2][0-3]):([0-5][0-9])\s[P,A][M]$/;
objPatternsMsg.Time = 'This time field may contain the time in 12-hour format.&nbsp;&nbsp;Example:  &quot;12:45&nbsp;PM&quot;';

objPatternsDict.Year = /^\d{4}$/;
objPatternsMsg.Year = 'This year field may contain four numeric characters.&nbsp;&nbsp;Example: &quot;2001&quot;';

objPatternsDict.ZipCode = /^\d{5}(-\d{4})?$/;
objPatternsMsg.ZipCode = 'This zip code field may contain numeric data formatted like the example.&nbsp;&nbsp;Example:  &quot;78671&quot; or &quot;78671-0034&quot;';

objPatternsDict.SSN = /^\d{3}-\d{2,3}-\d{3,4}$/;
objPatternsMsg.SSN = 'This SSN/SIN field must be formatted correctly. &nbsp;Example: &quot;123-45-6789&quot; or &quot;123-456-789&quot;.';

<!-- end hide -->

//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------

function DoubleCheckMultiSelectsAny(strMultiSelect)
{
	var arrMultiSelect = cbGetElementById(strMultiSelect).options;
	var lngCounter;
	var blnReset;
	
	blnReset = false;
	for (lngCounter = 0; lngCounter < arrMultiSelect.length; lngCounter++)
	{
		if (arrMultiSelect[lngCounter].selected)
		{
			if (arrMultiSelect[lngCounter].value == '-99')
			{
				blnReset = true;
				break;
			}
		}
	}
	
	if (blnReset)
	{
		for (lngCounter = 0; lngCounter < arrMultiSelect.length; lngCounter++)
		{
			if (arrMultiSelect[lngCounter].value == '-99')
			{
				arrMultiSelect[lngCounter].selected = true;
			}
			else
			{
				arrMultiSelect[lngCounter].selected = false;
			}
		}
	}
}

function DisplayErrors()
{
	cbOpenDialog('/CMS/SystemMsg/ErrorReportNew.asp', null,                    'center:yes; help:no; resizable:no; scroll: yes; status:no; dialogWidth:350px; dialogHeight:280px');
}

/*'**************************************************************************
'* Program:	CheckRequiredRadioGroup
'*
'* Created By/Date:	Michael Howard - 1/13/2003
'*
'* Purpose: To add an error as part of a validation routine if the
'*					one of the radio buttons of the specified radio button
'*					group (strRadioName) has not been checked.
'*
'* Return Value:		NONE 
'*
'* Input Parameters:
'*
'*		strRadioName - string identifying the name attribute assigned
'*									 to the radio buttons in question
'*
'*		errorName - string denoting the description of the error that
'*								will be displayed on the error dialog box
'*
'*****************************************************************************/
function CheckRequiredRadioGroup(strRadioName, errorName)
{
	var rdoCalcTypes = cbGetElementsByName(strRadioName);
	var blnReturn = false;
			
	for (intCounter = 0; intCounter < rdoCalcTypes.length; intCounter++)
	{
		if (rdoCalcTypes[intCounter].checked)
		{
			blnReturn = true;
			break;
		}
	}
				
	if (!blnReturn)
	{
		AddError(rdoCalcTypes[0], strTabFormGoToErrorFunction(rdoCalcTypes[0].id), errorName, true, '');
	}
		
	return blnReturn;
}// end function CheckRequiredRadioGroup

function processVal(strFormValue)
{
	while(strFormValue.charAt(0) == ' ')
	{
		strFormValue = strFormValue.substring(1,strFormValue.length); 
	}
	while(strFormValue.charAt(strFormValue.length-1) == ' ')
	{
		strFormValue = strFormValue.substring(0,strFormValue.length-1); 
	}
	return strFormValue
}

function isElement(vElement)
{
/*'***************************************************************	
'* Program: 				isElement()
'*
'* Created By/Date:	James Laughlin 4/4/2002
'*
'* Purpose: 				This function loops through the forms
'*									on a page and checks to see if the passed
'*									in value is one of the elements on that page
'*
'* Return Value:		Boolean
'*
'* Input Parameters:	vElement - the name of the element that you
'*										are looking for
'*				
'* Modified:	Person / Date / Reason:
'*	
'******************************************************************/
	var bRetVal;
	var arrForms = document.forms;
	var arrElements;
	var lngCounter, lngCounter2;
	
	bRetVal = false;
	
	for(lngCounter = 0; lngCounter < arrForms.length; lngCounter++)
	{
		arrElements = arrForms[lngCounter].elements;
		for(lngCounter2 = 0; lngCounter2 < arrElements.length; lngCounter2++)
		{
			//loop through the elements in this form
			if (arrElements[lngCounter2].id == vElement)
			{
				//we found the element...return true.
				return true;
			}
		}
	}
	//found no such element...returning false
	return false;
}

function validateForm(theForm, blnImmediateOutput)
{
	var arrFormElements = theForm.elements; 
	var blnIsValid, blnIsValidTemp;
	var intCounter;
	
	
	if (arguments.length == 1)
	{
		blnImmediateOutput = true;
	}

	blnIsValid = true;
	
	strErrorWindowOutput = '';
	
	for (intCounter = 0; intCounter < arrFormElements.length; intCounter++)
	{
		blnIsValidTemp = validateElementSilent(arrFormElements[intCounter], false, true);
		blnIsValid = blnIsValid && blnIsValidTemp;
	}
	
	// Check if we are returning this immediately
	if (blnImmediateOutput)
	{
		// OK. We want to display now, so check if there were errors
		if (strErrorWindowOutput != '')
		{
			// There were errors, so call showErrors
			DisplayErrors();
		}
	}
	return blnIsValid;
}

function AddError(theElement, strFunction, strEnglishName, blnIsRequired, strPatternMessage, intMinLength, intMaxLength)
{
	switch (arguments.length)
	{
		case 1:
			strFunction = '';
		case 2:
			strEnglishName = cbAttribute(theElement, 'ErrorName');
			if (strEnglishName == null)
			{
				strEnglishName = cbAttribute(theElement, 'name');
			}
		case 3:
			blnIsRequired = cbAttribute(theElement, 'required');
		case 4:
			strPatternMessage = objPatternsMsg[cbAttribute(theElement, 'validator')];
		case 5:
			intMinLength = null;
		case 6:
			intMaxLength = null;
	}

	strErrorWindowOutput += '<LI><B>' + strEnglishName + '</B><BR>&nbsp;&nbsp;&nbsp;&nbsp;';
	if (blnIsRequired != null)
	{
		strErrorWindowOutput += '(This field is required and may not be left blank)&nbsp;';
	}

	if (intMinLength != null || intMaxLength != null)
	{
		strErrorWindowOutput += 'The length of this field must be ';
		if (intMinLength == intMaxLength)
		{
			strErrorWindowOutput += 'exactly ' + intMinLength;
		}
		else
		{
			if (intMinLength != null)
			{
				strErrorWindowOutput += 'a minimum of ' + intMinLength;
			}
			if (intMinLength != null && intMaxLength != null)
			{
				strErrorWindowOutput += ' and ';
			}
			if (intMaxLength != null)
			{
				strErrorWindowOutput += 'a maximum of ' + intMaxLength;
			}
		}
		strErrorWindowOutput += ' character(s).&nbsp;';
	}

	strErrorWindowOutput += strPatternMessage + '<BR></LI><BR>';

	if (strFunction != '')
	{
		strErrorWindowOutput += '<A HREF="#" OnClick="javascript:' + strFunction + '">';
	}
	else
	{
		if (cbAttribute(theElement, 'id')!= null)
		{
			strErrorWindowOutput += '<A HREF="#" name="GoToLink" TargetElement="' + cbAttribute(theElement, 'id') + '">';
		}
	}
	
	if(strFunction != '' || cbAttribute(theElement, 'id') != null)
	{
		strErrorWindowOutput += 'Go to this Item &gt;&gt;</A>';
	}
	
	strErrorWindowOutput += '<BR><BR>';
}

function DisableValidation(theElement, blnKeepValidator, blnKeepErrorName)
{
	switch (arguments.length)
	{
		case 0:
			return;
		case 1:
			blnKeepValidator = false;
			blnKeepErrorName = false;
			break;
		case 2:
			blnKeepErrorName = false;
			break;
		case 3:
			break;
	}
	
	cbAttribute(theElement, 'required', null);
	
	if (!blnKeepValidator)
	{
		cbAttribute(theElement, 'validator', null);
	}
		
	if (!blnKeepErrorName)
	{
		cbAttribute(theElement, 'ErrorName', null);
	}
}

function EnableValidation(theElement, strValidator, strErrorName, strExtra, strExtra2)
{
	switch (arguments.length)
	{
		case 0:
			break;
		case 4:
			switch (strValidator)
			{
				case 'DropDown':
					{
						if(strExtra != null)
						{
							cbAttribute(theElement, 'AllowZero', strExtra);
						}
						if(strExtra2 != null)
						{
							cbAttribute(theElement, 'AllowNegative', strExtra2);
						}
					}
					break;
			}			
		case 3:
			cbAttribute(theElement, 'ErrorName', strErrorName);
		case 2:
			cbAttribute(theElement, 'validator', strValidator);
		case 1:
			cbAttribute(theElement, 'required', true);
			break;
	}
}

function GetEnglishName(theElement)
{
	var strEnglishName = cbAttribute(theElement, 'ErrorName');
	if(strEnglishName == null || strEnglishName == '')
	{
		strEnglishName = cbAttribute(theElement, 'name');
	}
	if(strEnglishName == null || strEnglishName == '')
	{
		strEnglishName = cbAttribute(theElement, 'id');
	}
	if(strEnglishName == null || strEnglishName == '')
	{
		strEnglishName = '';
	}
	
	return strEnglishName;
}

function GetTheValue(theElement, blnGetTime)
{
	var strValue;

	if(blnGetTime == null)
	{
		blnGetTime = false;
	}
		
	// See if we are validating another attribute
	if (cbAttribute(theElement, 'validateAt') != null)
	{
		// Get the value of the element		
		strValue = processVal(cbAttribute(theElement, cbAttribute(theElement, 'validateAt')).toString());
	}
	else
	{
		// Get the value of the element		
		if (blnGetTime && (cbAttribute(theElement, 'Time') != null) && (cbGetElementById(cbAttribute(theElement, 'Time')).value.length != 0))
		{
			strValue = processVal(theElement.value) + ' ' + processVal(cbGetElementById(cbAttribute(theElement, 'Time')).value);
		}
		else
		{
			strValue = processVal(theElement.value);
		}
	}	
	
	return strValue;
}

/*'********************************************************************************
'* Program: ValidateElementSilent
'*
'* Modified:
'*	1/13/03 Michael Howard
'*			-	Added reference to 'AllowZero' attribute which precludes a
'*				zero value for dropdown lists if found
'*
'**********************************************************************************/
function validateElementSilent(theElement, blnImmediateOutput, blnWriteToOutput, blnResetOutput)
{
	var strValidator = cbAttribute(theElement, 'validator');
	var strPattern = new RegExp;
	var strName, strValue, strPattern, strPatternMessage;
	var strEnglishName;
	var blnIsValid, blnIsRequired, blnAllowZero, blnAllowNegative;
	var intMinLength, intMaxLength;
	var strTempValue;
	
	switch(arguments.length)
	{
		case 3:
			blnResetOutput = false;
	}
	
	// Let's see if we are resetting the error messages
	if (blnResetOutput)
	{
		strErrorWindowOutput = '';
	}

	// Assume it is true for th elements that don't validate
	blnIsValid = true;	

	// If the element is not displayed for some reason, we don't want to validate it
	if (cbDisplay(theElement) == 'none')
	{
		strValidator = '';
	}
	
	// If the element is not enabled, we don't want to validate it.
	if (theElement.enabled == false || theElement.disabled == true)
	{
		strValidator = '';
	}

	if (strValidator == null || strValidator == '')
	{
		strValidator = '';
	}
	
	// If there is a validator (even after previous test), do the validation
	if (strValidator)
	{
		// Get the element and English name (if there is one) to display
		strEnglishName = GetEnglishName(theElement);
		
		// Find out if this is a required field
		blnIsRequired = cbAttribute(theElement, 'required');
		if(blnIsRequired == '')
		{
			blnIsRequired = true;
		}
		
		// Get the value to validate against
		strValue = GetTheValue(theElement);

		if (theElement.tagName != 'SELECT' && !theElement.multiple)
		{
			if (cbAttribute(theElement, 'validateAt') != null)
			{
				cbAttribute(theElement, cbAttribute(theElement, 'validateAt'), strValue);
			}
			else
			{
				theElement.value = strValue;
			}
		}
		
		// Get the validator info
		strPattern  = objPatternsDict[strValidator];
		strPatternMessage = objPatternsMsg[strValidator];
		
		// Get the specific lengths
		intMinLength = cbAttribute(theElement, 'MinimumLength');
		intMaxLength = cbAttribute(theElement, 'MaximumLength');		
		
		// Determine if the value is valid
		if (strPattern == null)
		{
			strPatternMessage = 'Selected validation pattern is invalid.';
			blnIsValid = false;
		}
		else
		{
			if (strValidator != 'Password' && strValidator != 'StrictPassword')
			{
				//alert(strValidator + ' - ' + strPattern + ' = ' + strValue + ' - ' + strPattern.test(strValue));
				blnIsValid = strPattern.test(strValue);
			}
		}

		//alert('Ename - ' + strEnglishName);
		//alert('name - ' + cbAttribute(theElement, 'name'));
		//alert('val - ' + strValue);
		//alert('patt - ' + strPattern);
		//alert(Number(ScriptEngineMajorVersion() + '.' + ScriptEngineMinorVersion()));
		//alert('valid - ' + blnIsValid);
		//alert('req - ' + blnIsRequired);
		//alert(intMinLength);
		//alert(intMaxLength);

		// We have validated that the format of the date field is correct, now lets
		//	make sure that the value is a valid date	  
		if (strValidator == 'Date' || strValidator == 'Date8' || strValidator == 'Date10' || strValidator == 'DateBoth' || strValidator == 'QuarterlyDate')
		{
			strTempValue = GetTheValue(theElement, true);
			
			// We are checking a date, so make sure the value isn't empty
			if (strValue.length != 0)
			{
				// It's not empty, so check and update the validity
				try
				{
					blnIsValid = blnIsValid && isDate(strValue);
				}
				catch(e)
				{
					alert('DateUtilsNew.js was not included.');
					blnIsValid = false;
				}
				
				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceLessThan') != null)
					{
						var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceLessThan'));
						var FirstDate;
						var SecondDate;
						if (validateElementSilent(OtherElement, false, false, false))
						{
							if ((strTempValue.length > strValue.length) && (GetTheValue(OtherElement, true) > GetTheValue(OtherElement, false)))
							{
								FirstDate = new Date(FixDatesYear(strTempValue));
								SecondDate = new Date(FixDatesYear(GetTheValue(OtherElement, true)));
							}
							else
							{
								FirstDate = new Date(FixDatesYear(strValue));
								SecondDate = new Date(FixDatesYear(GetTheValue(OtherElement)));
							}

							if (FirstDate >= SecondDate)
							{
								blnIsValid = false;
								strPatternMessage = 'The ' + strEnglishName + ' field value must come before the ' + GetEnglishName(OtherElement) + ' field value.';
							}
						}
					}
				}

				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceLessThanDate') != null)
					{
						var FirstDate;
						var SecondDate = new Date(cbAttribute(theElement, 'ForceLessThanDate'));
						
						if ((strTempValue.length > strValue.length))
						{
							FirstDate = new Date(FixDatesYear(strTempValue));
						}
						else
						{
							FirstDate = new Date(FixDatesYear(strValue));
						}
						
						try { DebugToMenu('FLTD<BR>&nbsp;&nbsp;FD: ' + FirstDate + '<BR>&nbsp;&nbsp;SD: ' + SecondDate) } catch(e) {}
						
						if (FirstDate >= SecondDate)
						{
							blnIsValid = false;
							strPatternMessage = 'The ' + strEnglishName + ' field value must come before ' + cbAttribute(theElement, 'ForceLessThanDate') + '.';
						}
					}
				}
				
				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceGreaterThan') != null)
					{
						var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceGreaterThan'));
						var FirstDate;
						var SecondDate;
						if (validateElementSilent(OtherElement, false, false, false))
						{
							if ((strTempValue.length > strValue.length) && (GetTheValue(OtherElement, true) > GetTheValue(OtherElement, false)))
							{
								FirstDate = new Date(FixDatesYear(strTempValue));
								SecondDate = new Date(FixDatesYear(GetTheValue(OtherElement, true)));
							}
							else
							{
								FirstDate = new Date(FixDatesYear(strValue));
								SecondDate = new Date(GetTheValue(OtherElement));
							}
							if (FirstDate <= SecondDate)
							{
								blnIsValid = false;
								strPatternMessage = 'The ' + strEnglishName + ' field value must come after the ' + GetEnglishName(OtherElement) + ' field value.';
							}
						}
					}
				}

				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceGreaterThanDate') != null)
					{
						var FirstDate;
						var SecondDate = new Date(cbAttribute(theElement, 'ForceGreaterThanDate'));

						if ((strTempValue.length > strValue.length))
						{
							FirstDate = new Date(FixDatesYear(strTempValue));
						}
						else
						{
							FirstDate = new Date(FixDatesYear(strValue));
						}

						if (FirstDate <= SecondDate)
						{
							blnIsValid = false;
							strPatternMessage = 'The ' + strEnglishName + ' field value must come after ' + cbAttribute(theElement, 'ForceGreaterThanDate') + '.';
						}
					}
				}

				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceLessEqualThan') != null)
					{
						var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceLessEqualThan'));
						var FirstDate;
						var SecondDate;
						if (validateElementSilent(OtherElement, false, false, false))
						{
							if ((strTempValue.length > strValue.length) && (GetTheValue(OtherElement, true) > GetTheValue(OtherElement, false)))
							{
								FirstDate = new Date(FixDatesYear(strTempValue));
								SecondDate = new Date(FixDatesYear(GetTheValue(OtherElement, true)));
							}
							else
							{
								FirstDate = new Date(FixDatesYear(strValue));
								SecondDate = new Date(GetTheValue(OtherElement));
							}
							if (FirstDate > SecondDate)
							{
								blnIsValid = false;
								strPatternMessage = 'The ' + strEnglishName + ' field value must be equal to or come before the ' + GetEnglishName(OtherElement) + ' field value.';
							}
						}
					}
				}

				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceLessEqualThanDate') != null)
					{
						var FirstDate;
						var SecondDate = new Date(cbAttribute(theElement, 'ForceLessEqualThanDate'));

						if ((strTempValue.length > strValue.length))
						{
							FirstDate = new Date(FixDatesYear(strTempValue));
						}
						else
						{
							FirstDate = new Date(FixDatesYear(strValue));
						}

						if (FirstDate > SecondDate)
						{
							blnIsValid = false;
							strPatternMessage = 'The ' + strEnglishName + ' field value must be equal to or come before ' + cbAttribute(theElement, 'ForceLessEqualThanDate') + '.';
						}
					}
				}
				
				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceGreaterEqualThan') != null)
					{
						var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceGreaterEqualThan'));
						var FirstDate;
						var SecondDate;
						if (validateElementSilent(OtherElement, false, false, false))
						{
							if ((strTempValue.length > strValue.length) && (GetTheValue(OtherElement, true) > GetTheValue(OtherElement, false)))
							{
								FirstDate = new Date(FixDatesYear(strTempValue));
								SecondDate = new Date(FixDatesYear(GetTheValue(OtherElement, true)));
							}
							else
							{
								FirstDate = new Date(FixDatesYear(strValue));
								SecondDate = new Date(GetTheValue(OtherElement));
							}

							try{DebugToMenu('ForceGE<BR>&nbsp;&nbsp;FD: ' + FirstDate + '<BR>&nbsp;&nbsp;SD: ' + SecondDate);}catch(e){}

							if (FirstDate < SecondDate)
							{
								blnIsValid = false;
								strPatternMessage = 'The ' + strEnglishName + ' field value must be equal to or come after the ' + GetEnglishName(OtherElement) + ' field value.';
							}
						}
					}
				}

				if (blnIsValid)
				{
					if (cbAttribute(theElement, 'ForceGreaterEqualThanDate') != null)
					{
						var FirstDate;
						var SecondDate = new Date(cbAttribute(theElement, 'ForceGreaterEqualThanDate'));

						if ((strTempValue.length > strValue.length))
						{
							FirstDate = new Date(FixDatesYear(strTempValue));
						}
						else
						{
							FirstDate = new Date(FixDatesYear(strValue));
						}

						if (FirstDate < SecondDate)
						{
							blnIsValid = false;
							strPatternMessage = 'The ' + strEnglishName + ' field value must be equal to or come after ' + cbAttribute(theElement, 'ForceGreaterEqualThanDate') + '.';
						}
					}
				}
			}
			
			if(strValidator == 'QuarterlyDate')
			{
				var theTestDate = new Date(FixDatesYear(strValue));
				blnIsValid = (((theTestDate.getMonth() == 0) || (theTestDate.getMonth() == 3) || (theTestDate.getMonth() == 6) || (theTestDate.getMonth() == 9)) && (theTestDate.getDate() == 1))
			}
		} // if (strValidator = 'Date'
		
		// Can't get the regular expression working for this, so I'll code it manually.
		if (strValidator == 'StrictPassword')
		{
			// Assume the password is correct
			blnIsValid = true;
			
			// Set the variable to check for size
			intMinLength = 6;
			intMaxLength = 25;

			// Use a RegEx to test if there are any lower case chars
			strPattern  = objPatternsDict['LowerCase'];
			if (!strPattern.test(strValue))
			{
				blnIsValid = false;
			}

			// Use a RegEx to test if there are any upper case chars
			//strPattern  = objPatternsDict['UpperCase'];
			//if (!strPattern.test(strValue))
			//{
			//	blnIsValid = false;
			//}

			// Use a RegEx to test if there are numbers 
			strPattern  = objPatternsDict['Number'];
			if (!strPattern.test(strValue))
			{
				blnIsValid = false;
			}
			
			// Now check if we are doing a confirm
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ConfirmPassword') != null)
				{
					var OtherElement = cbGetElementById(cbAttribute(theElement, 'ConfirmPassword'));
					if (validateElementSilent(OtherElement, false, false, false))
					{
						if (OtherElement.value != strValue)
						{
							blnIsValid = false;
							strPatternMessage = '.  <b><FONT color=red>Passwords do not match.</FONT><B>';
						}
					}
				}
			}
			
			// Now see if CompareName1 needs processing
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'CompareName1') != null)
				{
					var CompareName = cbGetElementById(cbAttribute(theElement, 'CompareName1'));
					var strTempValue = theElement.value.toLowerCase();
					var strTempCompare = CompareName.value.toLowerCase();
					if (strTempCompare.length != 0)
					{
						if (strTempValue.indexOf(strTempCompare) != -1)
						{
							blnIsValid = false;
							strPatternMessage = '. <B><FONT color=red>Password contains your first name.</FONT></B>';
						}
					}
				}
			}

			// Now see if CompareName2 needs processing
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'CompareName2') != null)
				{
					var CompareName = cbGetElementById(cbAttribute(theElement, 'CompareName2'));
					var strTempValue = theElement.value.toLowerCase();
					var strTempCompare = CompareName.value.toLowerCase();
					if (strTempCompare.length != 0)
					{
						if (strTempValue.indexOf(strTempCompare) != -1)
						{
							blnIsValid = false;
							strPatternMessage = '. <B><FONT color=red>Password contains your last name.</FONT></B>';
						}
					}
				}
			}
		}
		
		// Percentage validation is a little special
		if (strValidator == 'Percentage')
		{
			if (parseInt(strValue, 10) < 0 || parseInt(strValue, 10) > 100)
			{
				blnIsValid = false;
			}
		}
		
		// Allow neg in decimals and currency
		if (strValidator == 'Decimal' || strValidator == 'Currency')
		{		
			// Check if the drop down can allow negative values
			blnAllowNeg = eval(cbAttribute(theElement, 'AllowNegative'));

			if (blnAllowNeg == null)
			{
				blnAllowNeg = false;
			}
			
			if (!blnAllowNeg)
			{
				// We can't allow negative numbers, so check if it is
				if (strValue.substring(0, 1) == '-')
				{
					// It is, so invalidate
					blnIsValid = false;
				}
			}
		}


		// Drop down validation are a little special, so check if this is drop down
		if (strValidator == 'DropDown')
		{
			// Check if the drop down can allow negative values
			blnAllowNeg = eval(cbAttribute(theElement, 'AllowNegative'));
			if (blnAllowNeg == null)
			{
				blnAllowNeg = false;
			}
			
			if (!blnAllowNeg)
			{
			
				// We can't allow negative numbers, so check if it is
				if (strValue.substring(0, 1) == '-')
				{
				
					// It is, so invalidate
					blnIsValid = false;
					
				}
			}

			// Check if the drop down can allow zero (added 1/13/03 MSH)
			blnAllowZero = eval(cbAttribute(theElement, 'AllowZero'));
			if (blnAllowZero == null)
			{
				blnAllowZero = false;
			}
			
			if (!blnAllowZero)
			{
				// We can't allow zero, so check if it is
				if (strValue == '0')
				{
					// It is, so invalidate
					blnIsValid = false;
				}
			}
		}

		// If this is a number, we need to test for ForceGreaterThanNumber, etc
		if (strValidator == 'Numeric')
		{
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceGreaterThanNumber') != null)
				{
					if (parseInt(strValue,10) <= parseInt(cbAttribute(theElement, 'ForceGreaterThanNumber'),10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be greater than ' + cbAttribute(theElement, 'ForceGreaterThanNumber') + '.';
					}
				}
			}
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceGreaterEqualThanNumber') != null)
				{
					if (parseInt(strValue,10) < parseInt(cbAttribute(theElement, 'ForceGreaterEqualThanNumber'),10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be greater than or equal to ' + cbAttribute(theElement, 'ForceGreaterEqualThanNumber') + '.';
					}
				}
			}
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceLessThanNumber') != null)
				{
					if (parseInt(strValue,10) >= parseInt(cbAttribute(theElement, 'ForceLessThanNumber'),10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be less than ' + cbAttribute(theElement, 'ForceLessThanNumber') + '.';
					}
				}
			}
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceLessEqualThanNumber') != null)
				{
					if (parseInt(strValue,10) > parseInt(cbAttribute(theElement, 'ForceLessEqualThanNumber'),10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be less than or equal to ' + cbAttribute(theElement, 'ForceLessEqualThanNumber') + '.';
					}
				}
			}

			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceGreaterThan') != null)
				{
					var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceGreaterThan'))
					if (parseInt(strValue,10) <= parseInt(OtherElement.value,10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be greater than ' + cbAttribute(OtherElement, 'ErrorName') + '.';
					}
				}
			}
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceGreaterEqualThan') != null)
				{
					var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceGreaterEqualThan'))
					if (parseInt(strValue,10) < parseInt(OtherElement.value,10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be greater than or equal to ' + cbAttribute(OtherElement, 'ErrorName') + '.';
					}
				}
			}
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceLessThan') != null)
				{
					var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceLessThan'))
					if (parseInt(strValue,10) >= parseInt(OtherElement.value,10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be less than ' + cbAttribute(OtherElement, 'ErrorName') + '.';
					}
				}
			}
			if (blnIsValid)
			{
				if (cbAttribute(theElement, 'ForceLessEqualThan') != null)
				{
					var OtherElement = cbGetElementById(cbAttribute(theElement, 'ForceLessEqualThan'))
					if (parseInt(strValue,10) > parseInt(OtherElement.value,10))
					{
						blnIsValid = false;
						strPatternMessage = 'The ' + strEnglishName + ' field value must be less than or equal to ' + cbAttribute(OtherElement, 'ErrorName') + '.';
					}
				}
			}
		}

		// See if we need to valid min length
		if (intMinLength != null)
		{
			if (strValue.length < intMinLength)
			{
				blnIsValid = false;
			}
		}
		
		// See if we need to validate max length
		if (intMaxLength != null)
		{
			if (strValue.length > intMaxLength)
			{
				blnIsValid = false;
			}
		}

		if (blnIsRequired == false)
		{
			blnIsRequired = null;
		}
				
		// Now we want to see if it's a required field.
		if (blnIsRequired != null)
		{
			// It is a required field, so check if it's blank
			if (strValue.length == 0)
			{
				// It's blank, so invalidate it.
				blnIsValid = false;
			}
		}
		else
		{
			// It's not required, so it will always be valid
			if (strValue.length == 0)
			{
				// It's blank, so we don't want it to be invalid
				blnIsValid = true;
			}
		}

		// We've done all the checking. Continue if this is valid								
		if (!blnIsValid)
		{
			if (blnWriteToOutput)
			{
				AddError(theElement, '', strEnglishName, blnIsRequired, strPatternMessage, intMinLength, intMaxLength);
			}
		}
	} // if strValidator

	// Check if we are returning this immediately
	if (blnImmediateOutput)
	{
		// OK. We want to display now, so check if there were errors
		if (strErrorWindowOutput != '')
		{
			// There were errors, so call showErrors
			//alert(strErrorWindowOutput);
			DisplayErrors();
		}
	}

	return blnIsValid;
}
