		var numErrs = 0;
		var errs = new Array();
		function errorMessages(message)
		{
			for(var i=0; i<numErrs; i++) {
				if (errs[i] == message) return;
			}
			errs[numErrs] = message;
			numErrs++;
		}
		function regError(code, handle) {
			var desc = '';
			switch (code) {
				case ('wholenumber'): desc = 'Must be a whole number'; break;
				case ('commas'): desc = 'Contains commas'; break;
				case ('invalidnum'): desc = 'Not a valid number'; break;
				default: desc = '';
			}
			if (desc != '') errorMessages(desc);
		}
		function getErrorMessages() {
			var messages = '';
			for(var i=0; i<errs.length; i++) {
				if (messages != '') messages += '\n';
				messages += errs[i];
			}
			return messages;
		}
		var errs;
		function initError() {
			errs = new Array('message', 'code', 'action');
			errs['message'] = new Array();
			errs['code'] = new Array();
			errs['action'] = new Array();
		}
		function addError(message, code, action) {
			var numEls = errs['message'].length;
			errs['message'][numEls] = message;
			errs['code'][numEls] = code;
			errs['action'][numEls] = action;
		}
		function regError(message, code, action) {
			if (message == null) {
				message = errorCodeToMessage(code);
			}
			for(var i=0; i<errs['message'].length; i++) {
				if (errs['message'][i] == message) return;
			}
			addError(message, code, action);
		}
		function errorCodeToMessage(code) {
			var desc = '';
			if (typeof clientErrorMessages != 'undefined') {
				desc = clientErrorMessages(code);
			}
			else {
				switch (code) {
					case ('wholenumber'): 
						desc = 'Must be a whole number'; 
						break;
					case ('commas'): 
						desc = 'Contains commas'; 
						break;
					case ('invalidnum'): 
						desc = 'Not a valid number'; 
						break;
					default: 
						desc = '';
				}
			}
			return desc;
		}
		function getErrorMessages() {
			var messages = '';
			for(var i=0; i<errs['message'].length; i++) {
				if (messages != '' && errs['message'][i] != '') messages += '\n';
				messages += errs['message'][i];
			}
			return messages;
		}
		function getErrorAction() {
			var action = '';
			for(var i=0; i<errs['action'].length; i++) {
				if (action != '') action += ',';
				switch (errs['action'][i]) {
					case ('clear'): 
						action = 'clear';
						return action;
						break;
					case ('remDec'): 
						action += 'remDec';
						break;
					case ('remComm'): 
						action += 'remComm';
						break;
					default: 
				}
			}
			return action;
		}
		function showHideContainer(containerName, el, vals, reset) {
			var show = false;
			var cnt;
			if (vals.substring(0,2) == "!=") {
				var vals = vals.substring(2,vals.length);
				var val = vals.split(',');
				show = true;
				if (el) {
					for (var i=0; i<val.length; i++) {
						if (el.value == val[i]) {
							if (el.tagName.toLowerCase() == 'input' && el.type != null) {
								if ((el.type.toLowerCase() == 'radio' || el.type.toLowerCase() == 'checkbox') && el.checked)	{
									show = false;
								}
								else	{
									//Leave show what it is.
								}
							}
							else	{
								show = false;
							}
						}
					}
				}				
			}
			else	{
				var val = vals.split(',');
				if (el) {
					for (var i=0; i<val.length; i++) {
						if (el.value == val[i]) {
							show = true;
							if (el.tagName.toLowerCase() == 'input' && el.type != null) {
								if (el.type.toLowerCase() == 'radio' && !el.checked) show = false;
								if (el.type.toLowerCase() == 'checkbox' && !el.checked) show = false;
							}
						}
						else {
							if (el.tagName.toLowerCase() == 'input' && el.type != null) {
								if (el.type.toLowerCase() == 'checkbox') return;
							}
						}
					}
				}
			}
			var containers = containerName.split(',');
			for (var j=0; j<containers.length; j++) {
				cnt = document.getElementById(containers[j]);
				if (cnt) {
					if (show) {
						cnt.style.display = getDisplayType(cnt);
						//To account for mac issue
						cnt.style.display = 'none';
						cnt.style.display = getDisplayType(cnt);
					}
					else {
						if (cnt.style.display != 'none') {
							cnt.style.display = 'none';
							if (reset) resetContainer(cnt);
						}
					}
				}
			}
			return false;
		}
		function showContainer(containerName) {
			var containers = containerName.split(',');
			for (var j=0; j<containers.length; j++) {
				cnt = document.getElementById(containers[j]);
				if (cnt) cnt.style.display = getDisplayType(cnt);
			}
			return false;
		}
		function getDisplayType(el) {
			if (el.tagName.toLowerCase() == 'table' || el.tagName.toLowerCase() == 'div') {
				return 'block';
			}
			else {
				return 'inline';
			}
		}
		function resetContainer(el) {
			if (el) {
				var children = el.children;
				for (var i=0; i<children.length; i++) {
					if (children[i].tagName.toLowerCase() == 'input') {
						if (children[i].type != null) {
							if (children[i].type.toLowerCase() == 'radio') {
								children[i].checked = false;
								if (children[i].onclick != null) children[i].onclick();
							}
							else { if (children[i].type.toLowerCase() == 'checkbox') {
								children[i].checked = false;
								if (children[i].onclick != null) children[i].onclick();
							}
							else { if (children[i].type.toLowerCase() == 'submit') {
								// do nothing
							}
							else {
								children[i].value = '';
							}}}
						}
					}
					else if (children[i].tagName.toLowerCase() == 'select') {
						if (children[i].multiple != null && children[i].multiple) children[i].selectedIndex = -1;
						else children[i].selectedIndex = 0;
						if (children[i].onchange != null) children[i].onchange();
					}
					resetContainer(children[i]);
				}
			}
			return;
		}
		function showLegend(legendName) {
			var legends = legendName.split(';');
			for (var i=0; i<legends.length; i++) {
				if (legends[i] != '') {
					var el = document.getElementById(legends[i]);
					if (el) el.style.display = getDisplayType(el);
				}
			}
			return;
		}
		function hideLegend(legendName) {
			var legends = legendName.split(';');
			for (var i=0; i<legends.length; i++) {
				if (legends[i] != '') {
					var el = document.getElementById(legends[i]);
					if (el) el.style.display = 'none';
				}
			}
			return;
		}
			function triggerAllEvents(tagName) {
				var allForms = document.forms;
				var allEls;
				var trigger = false;
				for (var j=0; j<allForms.length; j++) {
					allEls = document.forms[j].getElementsByTagName(tagName);
					for (var i=0; i<allEls.length; i++) {
						if (allEls[i].tagName.toLowerCase() == tagName) {
							trigger = true;
							if (allEls[i].type != null) {
								if (allEls[i].type.toLowerCase() == 'radio') {
									if (allEls[i].checked != true) trigger = false;
								}
								if (allEls[i].type.toLowerCase() == 'checkbox') {
									if (allEls[i].checked != true) trigger = false;
								}
							}
						}
						if (trigger) {
							if (allEls[i].onchange != null) allEls[i].onchange();
							if (allEls[i].onclick != null) allEls[i].onclick();
							if (allEls[i].onblur != null) allEls[i].onblur();
							trigger = false;
						}
					}
				}
			}
			function checkStatusField(el, status) {
				if (el && status) {
					if ((el.value.length != 0) && (status.options[status.selectedIndex].value.length != 0)) {
						status.selectedIndex = 0;
						return false;
					}
					return true;
				}
			}
			function checkStatusParent(el, parent) {
				if (el && parent) {
					if (el.options) {
						if ((parent.value.length != 0) && (el.options[el.selectedIndex].value.length != 0)) {
							parent.value = '';
							return false;
						}
						return true;
					}
				}
			}
			function loadDropDown(aryList, list, blank, selVal, filter) {
				clearSelect(list);

				var addOption = true;
				var filters = new Array;
				if (filter) filters = filter.split(',');
				var optionEl = new Option();
						
				if (blank) list.add(optionEl);	//Blank option
						
				if (aryList['value']) {
					for (var i=0; i<aryList['value'].length; i++ ) {
						addOption = true;
						for (var j=0; j<filters.length; j++) {
							if (filters[j] == aryList['value'][i]) addOption = false;
						}
						if (addOption) {
							optionEl = new Option();
							optionEl.value = aryList['value'][i];
							optionEl.text = aryList['text'][i];
							list.add(optionEl);
							if (aryList['value'][i] == selVal) {
								optionEl.selected = true;
							}
						}
					}
					if (list.onchange != null) list.onchange();
				}	
			}
			function clearSelect(list) {	
				while(list.length != 0) {
					list.remove(0);
				}
			}
			function openWin(url, winName, features) {	
				var win = window.open(url, winName, features);
			}
			function clearText(el, defaultValue, maxLength) {
				if (el.value == defaultValue) {
					el.value = '';
					el.maxLength = maxLength;
					return false;
				}
				return true;
			}
			function resetText(el, defaultValue, maxLength) {
				if (el.value == '') {
					el.maxLength = defaultValue.length;
					el.value = defaultValue;
					return false;
				}
				return true;
			}

		/*
			'****************************************************************************
			'                              LbToKg	 	 								
			'****************************************************************************
			' Purpose:     Computes kilograms when given pounds. 						 
			'                                                                           
			' Input Parameters: fieldkg		--  kg object								
			'					fieldlb		--	lb object							    
			'					statusfield --	status field object						
			'                   decimal		--  Maximum # of allowed decimal places     
			'                   rangechk	--  True/False parameter whether or not to  
			'									perform range checking                  
			'                   rangelow	--  Low range value                         
			'                   rangehigh	--  High range value                        	
			'        									       							
			' Returns:          set fields                                              
			'                                                                           
			' Called Routines:  passNumValidation										
			'****************************************************************************
			*/
			function LbToKg(fieldlb, fieldkg, fieldstatus, decimal, rangechk, rangelow, rangehigh, conDecimals, reset) 
			{
				
				if (passNumValidation(fieldlb, fieldstatus, decimal, rangechk, rangelow, rangehigh))
				{
					if (conDecimals != "") 
					{
						var vDec = Math.pow(10, conDecimals)
					}
					else
					{
						var vDec = Math.pow(10, decimal)
					}
					var KGval = eval(fieldlb.value) / 2.204622621849 ;
					var KGval=Math.round(eval(fieldlb.value) / 2.204622621849 * vDec )/ vDec
					if (!isNaN(KGval)) {
						if (KGval > 199.58) KGval = 200;
						fieldkg.value = (KGval);
					}
					else {
						if (reset) fieldkg.value = '';
					}
					if (fieldstatus != "")
					{
						if (fieldstatus.options[fieldstatus.selectedIndex].value.length != 0)
						{
							fieldstatus.selectedIndex = 0;   
						} 
					} 
				}
			}
		/*
		'****************************************************************************
		'                              KgToLb 	 	 								
		'****************************************************************************
		' Purpose:      Computes pounds when given kilograms.  				     
		'                                                                           
		' Input Parameters: fieldkg		--  kg object								
		'					fieldlb		--	lb object							    
		'					statusfield --	status field object						
		'                   decimal		--  Maximum # of allowed decimal places     
		'                   rangechk	--  True/False parameter whether or not to  
		'									perform range checking                  
		'                   rangelow	--  Low range value                         
		'                   rangehigh	--  High range value                        	
		'        									       							
		' Returns:          set fields                                              
		'                                                                           
		' Called Routines:  passNumValidation										
		'****************************************************************************
		*/

		function KgToLb(fieldkg, fieldlb, fieldstatus, decimal, rangechk, rangelow, rangehigh, lbrangehigh, conDecimals, reset) 
		{	
			if (passNumValidation(fieldkg, fieldstatus, decimal, rangechk, rangelow, rangehigh))
			{
				if (conDecimals != "") 
				{
					var vDec = Math.pow(10, conDecimals)
				}
				else
				{
					var vDec = Math.pow(10, decimal)
				}
				var LBval = Math.round( (eval(fieldkg.value) * 2.204622621849) * vDec)/vDec;	
				if ((lbrangehigh != null && lbrangehigh != '') && (LBval > lbrangehigh)) { 
					LBval = lbrangehigh; 
				}
				if (!isNaN(LBval)) {
					if (lbrangehigh != null && lbrangehigh != '') {
						if (LBval > lbrangehigh) LBval = lbrangehigh;
					}
					fieldlb.value = (LBval);
				}
				else {
					if (reset) fieldlb.value = '';
				}
				if (fieldstatus != "")
				{
					var fldType = fieldstatus.type;
					if (fldType.indexOf("select-one") >= 0)
					{
						fieldstatus.selectedIndex = 0;    
					}
				}
			}

		}
		/*
		'****************************************************************************
		'                              convertLength 	 	                            
		'****************************************************************************
		' Purpose:      Converts Lengths				 						                 
		'																			
		' Input Parameters: fieldInput    --  Input field that is being validated and converted
		'                   inUnit        --  Input field unit
		'                   fieldInput2   --  Other input field needed to convert length (feet or inches)
		'                   fieldOut1     --  Field to put converted value in
		'                   fieldOut2     --  Other output field if converting to feet and inches
		'                   outUnit       --  Output field unit
		'                   decimal       --  Number of decimals the current field is allowed to have
		'                   rangechk      --  Do a range check? True or False
		'                   rangelow      --  Low value if doing a range check
		'                   rangehigh     --  High value if doing a range check
		'                   conDecimals   --  Number of decimals output field allows
		'
		' Returns:          set fields
		'
		' Called Routines:  passNumValidation
		'
		' HISTORY:
		'****************************************************************************
		*/
		function convertLength(fieldInput, inUnit, fieldInput2, fieldOut1, fieldOut2, outUnit,decimal, rangechk, rangelow, rangehigh, conDecimals, reset)
		{
			if (passNumValidation(fieldInput, '', decimal, rangechk, rangelow, rangehigh))
			{
				var vCM

				//**************************************************
				//  Get number of decimals for rounding output
				//**************************************************
				if (conDecimals != "") 
				{
					var vDec = Math.pow(10, conDecimals)
				}
				else
				{
					var vDec = Math.pow(10, decimal)
				}

				//**************************************************
				//  Convert to cm first
				//**************************************************
				if (inUnit != 0)
				{
					vCM = convertToCM(fieldInput, fieldInput2,inUnit );
				}
				else
				{
					vCM = eval(fieldInput.value)
				}

				//**************************************************
				//  Convert from cm to the desired output unit
				//**************************************************

				///				INCHES
				if (outUnit == 1)
				{
					if (!isNaN(vCM)) {
						fieldOut1.value = Math.round( (vCM / 2.54) * vDec)/vDec;
					}
					else {
						if (reset) fieldOut1.value = '';
					}
				}

				///				FEET AND INCHES
				else if (outUnit == 5)
				{
					var allin = (vCM / 2.54);

					var FTval = parseInt((allin / 12));
					var INval = Math.round( ( (allin - (FTval * 12) ) * vDec))/vDec;
		
					if (INval == 12)
					{
						FTval = (FTval + 1);
						INval = "0";
					}
					if (!isNaN(FTval)) {
						fieldOut1.value = FTval;
					}
					else {
						if (reset) fieldOut1.value = '';
					}
					if (!isNaN(INval)) {
						fieldOut2.value = INval;
					}
					else {
						if (reset) fieldOut2.value = '';
					}
				}

				///				CENTIMETERS
				else		
				{
					if (!isNaN(vCM)) {
						fieldOut1.value = Math.round(vCM * vDec )/ vDec;
						if (fieldOut1.value > 225) fieldOut1.value = 225;
					}
					else {
						if (reset) fieldOut1.value = '';
					}
				}
			}
		}
		/*
		'****************************************************************************
		'                              convertToCM 	 	                            
		'****************************************************************************
		' Purpose:      Converts Lengths				 						                 
		'																			
		' Input Parameters: fieldInput     --  Input 
		'                   fieldInput2    --  Other input field needed to convert length (feet or inches)
		'                   inUnit         --  Input field unit
		'****************************************************************************
		*/
		function convertToCM(fieldInput, fieldInput2, inUnit)
		{
			var vTotal, FtVal, InVal
			if (inUnit == 1)			// input is inches
			{

				if (fieldInput2.value == "")
				{ 
					FtVal = 0;
				}
				else
				{
					if (fieldInput.id == fieldInput2.id)
					{
						FtVal = 0
					}					
					else
					{
						FtVal = eval(fieldInput2.value) * 12;
					}
				}

				vTotal = (eval(FtVal) + eval(fieldInput.value)) * 2.54;
			}
			else if (inUnit == 2)		// input is feet
			{
				FtVal = eval(fieldInput.value) * 12;
				if (fieldInput2.value == "")
				{ 
					InVal = 0;
				}
				else
				{
					InVal = eval(fieldInput2.value);
				}

				vTotal = (eval(FtVal) + eval(InVal)) * 2.54;
			}
			else
			{
				// This will be used when other units of measure are needed.
			}

			return vTotal;
		}
		function convertAge(src, trg, srcUnit, trgUnit) {
			if (src && trg) {
				var srcVal = src.value;
				var outVal = srcVal;
				if (srcUnit && trgUnit) {
					srcUnit = srcUnit.toUpperCase();
					trgUnit = trgUnit.toUpperCase();
					if (srcVal != '' && isDecimal(srcVal)) {
						if (srcUnit == 'Y' && trgUnit == 'M') {
							outVal = srcVal * 12;
						}
						else if (srcUnit == 'M' && trgUnit == 'Y') {
							outVal = srcVal / 12;
						}
						if (isNaN(outVal)) outVal = srcVal;
					}
				}
				trg.value = outVal;
			}
			return;
		}
		function convertAgeViaRadio(src, trg, radName, otherUnit, toTrg) {
			var els = document.getElementsByName(radName);
			for (var i=0; i<els.length; i++) {
				if (els[i].checked) {
					if (toTrg) return convertAge(src, trg, els[i].value, otherUnit);
					else return convertAge(src, trg, otherUnit, els[i].value);
				}
			}
			return;
		}
		function convertZip(src1, src2, trg, inTxt) {
			if (src1 && src2 && trg) {
				var val = src1.value + inTxt + src2.value;
				if (val.charAt(val.length - 1) == inTxt) val = src1.value;
				trg.value = val;
			}
			else {
				window.status = 'Error converting zip code';
			}
			return;
		}

		function formatDate(el, format) {
			switch (format) {
				case ('mmddyyyy'):
					if (el.value.indexOf('/') > -1) {
						if (el.value.length < 10) {
							var elArr = el.value.split('/');
							if (elArr.length == 3) {
								if (elArr[0].length == 1) {
									elArr[0] = '0' + elArr[0];
								}
								if (elArr[1].length == 1) {
									elArr[1] = '0' + elArr[1];
								}
								el.value = elArr.join('/');
							}
						}
					}
					else {
						if (el.value.length == 8) {       
							var newDate;           
							newDate = el.value.substring(0,2)                        
								+ '/' + el.value.substring(2,4)                        
								+ '/' + el.value.substring(4,8);           
							el.value = newDate;       
						}
					}
					break;
				case ('mmyyyy'):
					if (el.value.length == 6) {       
						if (el.value.indexOf('/') < 0) {           
							var newDate;           
							newDate = el.value.substring(0,2)                        
							+ '/' + el.value.substring(2,6)            
							el.value = newDate;       
						}   
					}   
					break;
			}
			return;
		}
		function validateDate(el, format)
		{
  			var field = el.value;
			var nErrorCode=0;
			var strMonth = '';
			var strDelim1 = '';
			var strDay = '';
			var strDelim2 = '';
			var strYear = '';
			var strMessage = '';
			var strExample = '01/01/2003';

			if (format == 'mmyyyy') strExample = '01/2003';
				
			// check length of date 
			 
			if (field != '')
			{
				if ((format == 'mmddyyyy' && field.length !=10) || (format == 'mmyyyy' && field.length != 7))
				{
					nErrorCode=1;
					strMessage += 'The date (' + field + ') must be in the following format: ' + format + '';
					strMessage += '\nExample: ' + strExample;	
				}
				// parse string
				else 
				{
		      
				switch (format) {
					case ('mmddyyyy'):
						strMonth = field.substring(0, 2);		// month
						strDelim1 = field.substring(2, 3);		// '/'
						strDay = field.substring(3, 5);			// day
						strDelim2 = field.substring(5, 6);		// '/'
						strYear = field.substring(6, 10);		// year
						break;
					case ('mmyyyy'):
						strMonth = field.substring(0, 2);		// month
						strDelim1 = field.substring(2, 3);		// '/'
						strYear = field.substring(3, 7);		// year
						break;
				}
				
				//error checking
				if (strMonth < 1 || strMonth > 12) 
				{
					nErrorCode=1;
					strMessage += '\nMonth must be between 1 and 12.';
				}
				
				// check for alphas
				
				// valid numeric digits
				var digits = '0123456789';
				
				for (var i = 0; i < strMonth.length; i++)
				{
					if (digits.indexOf(strMonth.charAt(i)) < 0)
					{
						nErrorCode=2;
					}
				}
				if (nErrorCode==2) strMessage += '\nMonth must be a number.';

				if (format != 'mmyyyy') {
					for (var i = 0; i < strDay.length; i++)
					{
						if (digits.indexOf(strDay.charAt(i)) < 0)
						{
							nErrorCode=3;
						}
					}
					if (nErrorCode==3) strMessage += '\nDay must be a number.';
				}
				for (var i = 0; i < strYear.length; i++)
				{
					if (digits.indexOf(strYear.charAt(i)) < 0)
					{
						nErrorCode=4;
					}
				}
				if (nErrorCode==4) {
					if (format == 'yyyy') {
						strMessage += '\nPlease enter only the year.';
					}
					else {
						strMessage += '\nYear must be a number.';
					}
				}

 				if (format != 'mmyyyy') {
					if ((strDelim1 != '/') || (strDelim2 != '/'))
					{
						nErrorCode = 1;
						strMessage += '\nMonth, day, and year must be separated by /.'
					}
					if (strDay < 1 || strDay > 31) 
					{
						nErrorCode=1;
						strMessage += '\nDay must be between 1 and 31.';
					}
				}
        			if (strYear < 1900 || strYear > 2099) 
        			{
					nErrorCode=1;
					strMessage += '\nYear must be in the 20th or 21st Century.';
				}

				if (format != 'mmyyyy') {
        				// months with 30 days
        				if (strMonth==4 || strMonth==6 || strMonth==9 || strMonth==11)
        				{
						//alert(strDay);
						if (strDay==31) 
						{
							nErrorCode=1;
							strMessage += '\nThis month only has 30 days.';
						}
		  			}
				}

        		// February, leap year
				if (strMonth==2)
        			{
					var g=parseInt(strYear/4);
					if (isNaN(g)) 
					{
						nErrorCode=1;
					}
					if (strDay > 29) 
					{
						nErrorCode=1;
						strMessage += '\nLeap year Feb. only has 29 days.';
					}

					if (strDay==29 && ((strYear/4)!=parseInt(strYear/4))) 
					{
						nErrorCode=1;
						strMessage += '\nNon leap year Feb. only has 28 days.';
					}
				}
				}
			}
			// error handler
			if (nErrorCode >=1)
    		{
				alert(strMessage);
				el.value = '';
				el.focus();
				return (false);
			}
    		else
    		{
        		return (true);
    		}
		}
		function validateYear(el)
		{
			var strYear = el.value;

			if (strYear != '')
			{
				// check for alphas
				// valid numeric digits
				var digits = '0123456789';

				for (var i = 0; i < strYear.length; i++)
				{
					if (digits.indexOf(strYear.charAt(i)) < 0)
					{
						alert('Year must be numeric.');
						el.value = '';
						el.focus();
						return false;
					}
				}

				// check century
				if (strYear < 1900 || strYear > 2099)
				{
					alert('Year must be in the 20th or 21st Century.');
					el.value = '';
					el.focus();
					return false;
				}
				else
				{
					return true;
				}
			}
		}
		function validateDateRange(el, label, format, lowVal, highVal, lowValDisplay, highValDisplay) {
			if (label == '') label = 'This date';
			switch (format) {
				case ('mmyyyy'):
					var val = new Date(insertDays(el.value));
					var high = new Date(insertDays(highVal));
					var low = new Date(insertDays(lowVal));
					break;
				default:
					var val = new Date(el.value);
					var high = new Date(highVal);
					var low = new Date(lowVal);
					break;
			}
			if (val != '') {
				if (highVal) {
					if (val.valueOf() > high.valueOf()) {
						alert(label + ' must be before ' + highValDisplay + '.');
						el.value = '';
						el.focus();
						return false;
					}
				}
				if (lowVal) {
					if (val.valueOf() < low.valueOf()) {
						alert(label + ' must be after ' + lowValDisplay + '.');
						el.value = '';
						el.focus();
						return false;
					}
				}
			}
			return true;
		}
		function insertDays(someDate) {
			var ret = someDate;
			if (someDate.length == 7) {
				ret = ret.substring(0,3)
	    			+ '01/'
	    			+ ret.substring(3,7);
		}
			return ret;
		}
		function formatTime(el, hrfmt) {
			var fldVal = el.value;
			var fldLen = fldVal.length;
			var errMessage = '';
			var hr = 0;
			var min = 0;

			if (fldVal != "") {
				if ( fldLen == 4 ) {	// make : optional by converting hhmm to hh:mm
					fldVal = fldVal.substring( 0 , 2 ) + ":" + fldVal.substring( 2, 4 );
					el.value = fldVal;
					fldLen = fldVal.length;
				}

				if ( ((fldLen != 5) || (fldVal.charAt(2)) != ":") ) { 
					if (hrfmt) 
						errMessage = 'Invalid time format.  Should be ##:##.';
					else
						errMessage = 'Invalid time format.  Should be ##:##.';
					alert(errMessage);
					el.value = '';
						el.focus();
					return (false);
				}

				for (var y = 0; y < fldLen; y++)
				{
					if (y != 2) {
						var digit = fldVal.charAt(y);
						if (digit < "0" || digit > "9") {
						errMessage = 'Invalid character for time';
						alert(errMessage);
						el.value = '';
						el.focus();
						return (false);
					}
				}
			}

			hr = parseInt(fldVal.substring(0, 2))
			min = parseInt(fldVal.substring(3, 5))

			if ((hrfmt == true) && ((min > 59) || (hr > 23))) {
				errMessage = 'Invalid time format (24hr)';
				alert(errMessage);
				el.value = '';
						el.focus();
				return (false);
			}
			else if ((hrfmt == false) && ((min > 59) || (hr > 12))) {
				errMessage = 'Invalid time format (12hr)';
				alert(errMessage);
				el.value = '';
				el.focus();
				return (false);
			}
			else
			{
				return (true);
			}}
		}
		function validateNumeric(field, statusField, decimal, rangechk, rangelow, rangehigh, label, lowLabel, highLabel, unit)
		{
			initError();
			var ret = true;
			var passed = passNumValidation(field, statusField, decimal, rangechk, rangelow, rangehigh);
			if (!passed) {
				modifyField(field, decimal);
				ret = false;
			}
			if (rangechk == 'True') passed = validateRange(field, label, rangelow, rangehigh, lowLabel, highLabel, unit); 
			if (ret && !passed) ret = passed;
			return ret;
		}
		function validateRange(field, label, rangelow, rangehigh, lowLabel, highLabel, unit)
		{
			initError();
			var passed = passRangeValidation(field, label, rangelow, rangehigh, lowLabel, highLabel, unit); 
			if (!passed) {
				modifyField(field, 0);
				return false;
			}
			return true;
		}
		function validateNumericFtIn(field1, field2, statusField, decimal, rangechk, rangelow, rangehigh, label, lowLabel, highLabel, unit, unitVal)
		{
			if (field1 && field2) {
				//For special cases where above 7 ft 5 in
				if ((unitVal == 'ft' && ((field1.value > 7) || (field1.value == 7 && field2.value > 5))) || (unitVal == 'in' && field1.value > 5 && field2.value >= 7)) {
					validateNumeric(field1, statusField, decimal, 'false', rangelow, rangehigh, label, lowLabel, highLabel, unit);
					if (label == '') label = 'This field';
					alert(label + ' must not exceed 7 ft 5 in');
					field1.value = '';
					return false;
				}
				else {
					return validateNumeric(field1, statusField, decimal, rangechk, rangelow, rangehigh, label, lowLabel, highLabel, unit);
				}
			}
			else {
				return validateNumeric(field1, statusField, decimal, rangechk, rangelow, rangehigh, label, lowLabel, highLabel, unit);
			}
		}
		function modifyField(field, decimal)
		{
			var messages = getErrorMessages();
			var action = getErrorAction();
			var actions = action.split(',');
			if (messages != '' && action != '') {
				alert(messages);
				for (var i=0; i<actions.length; i++) {
					switch (actions[i]) {
						case ('clear'): field.value = ''; field.focus(); break;
						case ('remDec'): stripDecimals(field, decimal); break;
						case ('remComm'): stripCommas(field); break;
						default:
					}
				}
			}
		}
		/*
		'****************************************************************************
		'                              passNumValidation                            
		'****************************************************************************
		' Purpose:          Perform numeric validation checks on specified field.   
		'                   If necessary, alert user if invalid.		            
		'                                                                           
		' Input Parameters: field		--  String containing number to verify                               
		'					statusfield --	status field object						
		'                   decimal		--  Maximum # of allowed decimal places     
		'                   rangechk	--  True/False parameter whether or not to  
		'									perform range checking                  
		'                   rangelow	--  Low range value                         
		'                   rangehigh	--  High range value                        
		'                                                                           
		' Returns:          True if the number is within the specified range,       
		'                   otherwise False.				                        
		'                                                                           
		' Called Routines:  isValidNumField                                         
		'                   isValidNumFmt                                           
		'                   isValidNumRange                                         
		'****************************************************************************
		*/

		function passNumValidation(field, statusField, decimal, rangechk, rangelow, rangehigh)
		{
			var fldVal = field.value;  
			var ret = true;       
			if (field.value == '' || field.value == null) {
				return ret;
			}
			else {
				if (statusField != '') {
					var fldType = statusField.type;
					if (fldType.indexOf("select-one") >= 0) {
						statusField.selectedIndex = 0; 
					}
				}
			}
			if (!isValidNumField(field)) {
				ret = false;
			}
			if (!isValidNumFmt(field, decimal)) { 
				if (decimal == 0) {
					//must be a whole number
					regError(null, 'wholenumber', 'remDec');
					ret =  false;
				}
				else {
					//required number of decimal
					regError('Does not contain required number of decimals: ' + decimal, '', 'remDec');
					ret =  false;
				}
			}     
			if ((rangechk == 'True') && (!isValidNumRange(fldVal, rangelow, rangehigh))) 
			{
			}
			return ret;
		}
		/*   
		'****************************************************************************
		'                               isValidNumFmt                               
		'****************************************************************************
		' Purpose:          Verify that a specified field contains a valid number   
		'                   format.                                                 
		'                                                                           
		' Input Parameters: fieldname --  String containing number to verify        
		'                   decimal   --  Maximum # of allowed decimal places       
		'                                                                           
		' Returns:          True if the number is formatted properly, otherwise     
		'                   False                                                   
		'                                                                           
		' Called Routines:  								
		'****************************************************************************
		*/

		function isValidNumFmt(el, decimal)
		{
			//check if decimal exists in string
			var fieldname = el.value;
			var x = fieldname.length
			var i = (fieldname.indexOf('.')) + 1 
			var z = x - i
		       
			if ((fieldname.indexOf('.')) < 0) { 
				return true;
			}
			else {
				if (decimal == 0) {
					return false;
				} 
				else { 
					if (z > decimal) {
						return false;
					} 
				}    
			}
			return true;
		}
		/*
		'****************************************************************************
		'                              isValidNumField                              
		'****************************************************************************
		' Purpose:          Verify that a specified field on the form contains a    
		'                   numeric entry.  Alerts user if the field                
		'                   contains non-numeric data.                              
		'                                                                           
		' Input Parameters: fieldname --  String containing number to verify        
		'                                                                           
		' Returns:          True if the field contains a numeric entry, otherwise   
		'                   False                                                   				
		'****************************************************************************
		*/

		function isValidNumField(el) {
			var ret = true;
			var val = el.value;
			if (val != '' && val != null) {
				for (var i=0; i < val.length; i++) {
					var digit = val.charAt(i)
					if (digit < '0' || digit > '9') {
						//not a number
						if (digit == ',') {
							//contains commas
							regError(null, 'commas', 'remComm');
							ret = false;
						} 
						else { if (digit == '.') {
							//decimal points okay
							return true;
						}
						else { if (digit == '-' && i == 0) {
							//okay if - is first char
							return true;
						}
						else {
							//not numeric
							regError(null, 'invalidnum', 'clear');
							ret = false;
						}}}
					}
				}
			}
			return ret;       
		}
		function passRangeValidation(el, label, lowVal, highVal, lowLabel, highLabel, unit) 
		{
			var msg = '';
			var unitLabel = unit;
			if (label == '') label = 'This field';
			if (lowLabel == '') lowLabel = lowVal;
			if (highLabel == '') highLabel = highVal;
			if (!isDecimal(unit.replace('-', ''))) unitLabel = '';
			if (el.value != '' && el.value != null) {
				if (((lowVal != '' && lowVal != null) || (lowVal == 0)) && ((highVal != '' && highVal != null) || (highVal == 0))) {
					if (!(isValidNumRange(el.value, lowVal, highVal))) {
						msg = label + ' must be between ' + lowLabel + ' ' + unitLabel + ' and ' + highLabel + ' ' + unitLabel;
					}
				}
				else {
					if ((lowVal != '' && lowVal != null) || (lowVal == 0)) {
						if (parseFloat(el.value) < parseFloat(lowVal)) {
							msg = label + ' must be greater than or equal to ' + lowLabel + ' ' + unitLabel;
						}
					}
					if ((highVal != '' && highVal != null) || (highVal == 0)) {
						if (parseFloat(el.value) > parseFloat(highVal)) {
							msg = label + ' must be less than or equal to ' + highLabel + ' ' + unitLabel;
						}
					}
				}
				if (msg != '') {
					//errorMessages(msg);
					regError(msg, '', 'clear');
					return false;
				}
			}
			return true;
		}
		/*
		'****************************************************************************
		'                              isValidNumRange                              
		'****************************************************************************
		' Purpose:          Verify that a specified field contains a valid number   
		'                   range.                                                  
		'                                                                           
		' Input Parameters: fieldname --  String containing number to verify        
		'                   rangelow  --  Low range value                           
		'                   rangehigh --  High range value                          
		'                                                                           
		' Returns:          True if the number is within the specified range,       
		'                   otherwise False					      
		'                                                                           
		' Called Routines:  																							    
		'****************************************************************************
		*/

		function isValidNumRange(fieldname, rangelow, rangehigh)
		{
			var fieldvalue;
			fieldvalue = parseFloat(fieldname);
			if ((fieldvalue >= parseFloat(rangelow)) && (fieldvalue <= parseFloat(rangehigh))) {
				return (true);
			}
			else { 
				return (false);
			}
		}
		function isInteger(value)
		{
			return checkNumeric(value, '0123456789');
		}
		function isDecimal(value)
		{
			return checkNumeric(value, '0123456789.');
		}
		function checkNumeric(value, validChars)
		{
			var curChar = '';
			for (var i=0; i<value.length; i++) {
				curChar = value.charAt(i);
				if (validChars.indexOf(curChar) == -1) {
					return false;
				}
			}
			return true;
		}
		function stripDecimals(el, decimal) {
			//Strips off extraneous decimal places
			if (el && el.value.indexOf('.') > -1) {
				var num = el.value.length - el.value.indexOf('.') + 1;
				if (decimal == 0) {
					el.value = el.value.substring(0, el.value.indexOf('.'));
				}
				else{ if (num >= decimal) {
					el.value = el.value.substring(0, el.value.indexOf('.') + decimal + 1);
				}}
			}
		}
		function stripCommas(el) {
			if (el) {
				el.value = el.value.replace(',', '');
			}
		}
		/****************************************************************************
		' smartSelect_onKeyPress
		'****************************************************************************
		' Purpose:          Handles keystrokes for Select box.
		'
		' Called Routines:  smartSelect_closetValue
		'***************************************************************************/
		function smartSelect_onKeyPress()
		{
			objSelect = event.srcElement;
			if (objSelect == null) return;
			var intCode = event.keyCode;
			var charCode = String.fromCharCode(intCode).toUpperCase();

			var strSearch = objSelect.getAttribute("search");
			if (strSearch == null) strSearch = "";

			var timerID = objSelect.getAttribute("timer");
			if (timerID == null) timerID = -1;

			var strFlg = objSelect.getAttribute("flag");
			if (strFlg == null) strFlg = "";
			var bFind = false;

			if (timerID != -1)
				window.clearTimeout(timerID);

			// all characters (default)
			if (strFlg == "") {
				strSearch = strSearch + charCode;
				bFind=true;
			}
			// letters & numbers
			else if (strFlg == "LN" && ((charCode >= "a" && charCode <= "z") || (charCode >= "A" && charCode <= "Z") || (charCode >= "0" && charCode <= "9"))) {
				strSearch = strSearch + charCode;
				bFind=true;
			}
			// letters only
			else if (strFlg == "L" && ((charCode >= "a" && charCode <= "z") || (charCode >= "A" && charCode <= "Z" ))) {
				strSearch = strSearch + charCode;
				bFind=true;
			}
			// numbers only
			else if (strFlg == "N" && (charCode >= "0" && charCode <= "9")) {
				strSearch = strSearch + charCode;
				bFind=true;
			}
			objSelect.setAttribute("search", strSearch);
			window.status = "Find In List: " + strSearch;
			// find value in combo box and locate the correct drop down value
			if (bFind) {
				event.returnValue=false;
				event.cancelCapture = false;
				event.cancelBubble = false;

				timerID = window.setTimeout("smartSelect_clearSearch(document.getElementById('" + objSelect.id + "'));", 2000);
				objSelect.setAttribute("timer", timerID);

				var len = strSearch.length;
				for(x=0; x < len; x++)	
				{
					if (smartSelect_closetValue(objSelect, strSearch.substr(0, len-x)))
						return;
				}
			}
		}
		/****************************************************************************
		' smartSelect_onKeyDown
		'****************************************************************************
		' Purpose:          Handles keystrokes for Select box.
		'
		' Called Routines:  smartSelect_closetValue
		'***************************************************************************/
		function smartSelect_onKeyDown()
		{
			var objSelect = event.srcElement;
			if (objSelect == null) return;
			var intCode = event.keyCode;

			var strSearch = objSelect.getAttribute("search");
			if (strSearch == null) strSearch = "";

			var timerID = objSelect.getAttribute("timer");
			if (timerID == null) timerID = -1;

			var bFind = false;

			if (timerID != -1)
				window.clearTimeout(timerID);

			// backspace key was pushed
			if (intCode == 8) {
				strSearch = strSearch.substr(0,strSearch.length-1);
				bFind=true;
			}
			// delete key was pushed
			else if (intCode == 46) {
				strSearch = "";
				bFind=true;
			}
			if (bFind) {
				objSelect.setAttribute("search", strSearch);
				window.status = "Find In List: " + strSearch;

				event.returnValue=false;
				event.cancelCapture = false;
				event.cancelBubble = false;

				timerID = window.setTimeout("smartSelect_clearSearch(document.getElementById('" + objSelect.id + "'));", 2000);
				objSelect.setAttribute("timer", timerID);

				var len = strSearch.length;
				for(x=0; x < len; x++)	
				{
					if (smartSelect_closetValue(objSelect, strSearch.substr(0,len-x)))
						return;
				}
			}
		}
		/****************************************************************************
		' smartSelect_clearSearch
		'****************************************************************************
		' Purpose:          Clears search attribute.
		'***************************************************************************/
		function smartSelect_clearSearch(objSelect) {
			if (objSelect != null) {
				objSelect.setAttribute("search", "");
			}
			window.status = "";
			objSelect.setAttribute("timer", -1);
		}
		/****************************************************************************
        ' smartSelect_closetValue
        '****************************************************************************
        ' Purpose:          Determine if radio group 'yes' was checked.             
        '
        ' Returns:          True if the field if field is found and selects field.       
        '
        ' Called Routines:  none
        '***************************************************************************/
		function smartSelect_closetValue(objSelect, strValue)
		{
			var j = objSelect.selectedIndex;
			var len = objSelect.options.length;
			for(i=0; i < len; i++)
			{
				var strText = objSelect.options[i].text.toUpperCase();
				if (strValue == strText.substr(0,strValue.length))
				{
					if (i != j) {
						var onchange = objSelect.getAttribute("onchange");
						objSelect.selectedIndex=i;
						if ((onchange != null) && (onchange != ""))
							//eval(onchange + " anonymous();");
							objSelect.onchange();
					}
					return true;    
				}        
			}
			return false;
		}

		function trimAll(str) { 
			//Removes leading and trailing spaces.
			var objRegExp = /^(\s*)$/;

			//check for all spaces
			if(objRegExp.test(str)) {
				str = str.replace(objRegExp, '');
				if( str.length == 0)
				return str;
			}

			//check for leading & trailing spaces
			objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
			if(objRegExp.test(str)) {
				//remove leading and trailing whitespace characters
				str = str.replace(objRegExp, '$2');
			}
			return str;
		}
		function validateSSN(el) {
			if (!chkFmtSSN(el) && el.value != '') {
				alert('This SSN is invalid.');
				el.value = '';
				el.focus();
			}
		}
		/*
		'****************************************************************************
		'                              chkFmtSSN               	                    
		'****************************************************************************
		' Purpose:          Validate SSN:  check length to be nine (9), check 	    
		'					whether or not numeric, CHECK PREFIX, and 				
		'					format number.			       							 
		'                                                                           
		' Input Parameters: field  --  	ssn object									
		'                 															
		'        																	
		' Returns:          set field												
		'                                                                           
		' Called Routines:  errorMessages                                           
		'****************************************************************************
		*/
		function chkFmtSSN(field) 
		{
			var save = field.value;
			// valid numeric digits
			var digits = "0123456789";

			// valid other digits
			var front3 = "9CH9FN9EX9ch9fn9ex";
			var front0 = "000";
			
			// check for hyphens
			if (save.length > 9)
			{	
				if (save.charAt(3) != "-")
				{	
					//errorMessages("chkThirdSSN");
					//field.focus();
					return (false);
				}
				else
				{
					if (save.charAt(6) != "-")
					{	
						//errorMessages("chkSeventhSSN");
						//field.focus();
						return (false);
					}
				}		
				// separate ssn parts
				var save1 = save.substring(0, 3);
				//alert (save1);
				var save2 = save.substring(4, 6);
				//alert (save2);
				var save3 = save.substring(7, save.length);
				//alert (save3);
				var SSNval = save1 + save2 + save3;
				var last6 = save2 + save3;
			}
			else
			{
				// separate ssn parts
				var save1 = save.substring(0, 3);
				//alert (save1);
				var save2 = save.substring(3, 5);
				//alert (save2);
				var save3 = save.substring(5, save.length);
				//alert (save3);
				var SSNval = save1 + save2 + save3;
				var last6 = save2 + save3;
			}
			
			// check for alphas
			var allnumeric = true;
			for (var i = 0; i < SSNval.length; i++)
			{
				if (digits.indexOf(SSNval.charAt(i)) < 0)
				{
					allnumeric = false;
				}
			}

			var valid;
			if (allnumeric && SSNval.length == 9)
			{
					//alert("Valid SSN");
					valid = true;
			}
			else
			{
				// check for other digits
				var frontok = false;
				if (front3.indexOf(save1) != -1)
				{
					frontok = true;
				}
				
				var lastok = true;
				for (var i = 0; i < SSNval.length; i++)
				{
					if (digits.indexOf(last6.charAt(i)) < 0)
					{
						lastok = false;
					}
				}
			
				if (frontok && lastok && SSNval.length == 9)
				{
					//alert("Valid OTHER");
					valid = true;
				}
				else
				{
					//alert("Not valid");
					valid = false;
				}
			}
			
			//added this code to check for all repeating numbers (00000000,11111111,ect...)
			if (valid)
			{
				valid = false
				for (var i = 0; i < SSNval.length; i++)
				{
					if (SSNval.charAt(i) != SSNval.charAt(0))
					{
						//set i to 99 to break the loop and set valid to true
						i = 99;
						valid = true;
					}
				}
			}
			
			//added this code to check for 1st 3 numbers = 000 - WO63988
			if (valid)
			{
				valid = false
				if (front0.indexOf(save1) != 0)
				{
					valid = true;
				}
			}
			
			//added this code to check for 1st number = 8 -  WO63988
			if (valid)
			{
				valid = false
				if (SSNval.charAt(0) != 8)
				{
					valid = true;
				}
			}
			
			//added this code to check for 1st number = 9 followed by only CH or FN -  WO63988
			if (valid)
			{
				valid = false
				if (SSNval.charAt(0) == 9)
				{
					if ((save1.indexOf('CH') == 1) || (save1.indexOf('ch') == 1) || (save1.indexOf('FN') == 1) || (save1.indexOf('fn') == 1) || (save1.indexOf('EX') == 1) || (save1.indexOf('ex') == 1))
					{
						valid = true;
					}
				}
				else
				{
					valid = true;
				}
			}
			
			if (valid)
			{
				//alert("Im good.");
				var SSNfmt = save1 + "-" + save2 + "-" + save3;
				//formatted = (SSNfmt);
				return true;
			}
			else
			{
				// check if SSN not equal ""
				if (save != "")
				{
					//errorMessages("notValidSSN");
					var SSNfmt = save1 + "-" + save2 + "-" + save3;
					//field.focus();
					//document.forms[0].fldchar.value = SSNfmt;
					return false;
				}
			}
		}



