function checkerr() {
	
	version="~DV1.2"
	/*
	VERSION HISTORY
	1.1 Added specific DV types that reformat input
			"t" for telephone formated numbers 
			"s" for social security numbers
			**** These DV types are buggy and should be used with caution!!
		Enhanced email to require 5 characters and disallow spaces
	*/

	   alert_string = ""
	   alert_flag = 0
        
        //cycle through the form elements - perhaps by number
	for (i = 0; i < document.contact.elements.length; i++)
	{
		
		fieldname = document.contact.elements[i].name.toString()
		value = document.contact.elements[i].value
		
		//alert("Fieldname is: " + fieldname + "\r Value is : " + value)
		
		//split the field name on "||"
		if (fieldname.indexOf("~DV") > -1)
    				{
    				//alert("Fieldname is: " + fieldname + "\r Value is : " + value)
    				//element 1 is DVcode | element 2 is Label | element 3 is fieldname | element 4 is popupflag
    				//~DV01n0||label||fieldname||0
    				the_split = fieldname.split("||")
    				DVcode = the_split[0]
    				label = the_split[1]
    				field_name = the_split[2]
    				popupflag = the_split[3]
    				if (popupflag == 1) {
    				//get the index number
    				index = document.contact[i].selectedIndex
    				value= document.contact[i].options[index].value
    				//alert("popupflag: " + popupflag)
    				//alert("value: " + value)
    				}
    				//alert(the_split + "|" + DVcode + "|" + label + "|" + field_name)

				/*within DVcode char 
					0-2 are placeholders 
					3-4 are action_code 
					5 is required y|n
					6 is validation_type
					if validation_type == 'L' split DVcode on !! - element 2 is the literal string
					if validation_type == 'f' split DVcode on !! - element 2 is the format string
					if validation_type == 'n' 7-end is the number of digits required in the field
				*/
		
				action_code = DVcode.substring(3,5)
				//action_code functions go here!!
				required = DVcode.substring(5,6)
				validation_type = DVcode.substring(6,7)
				//alert("Codes " + action_code + "|" + required + "|" + validation_type)
				
			//do validation
			if (required == "y" && (!value || value == "null" || value == "" || value == " "))
				{alert_flag = 1; alert_string += label + " is a required field.\r";}
			
			//if validation_type == 'U || T || l ' - these functions don't set errors - they just fix any trouble
			
			if (validation_type == 'U') // UPPERCASE
				{
					//just change it
					document.contact[i].value = value.toString().toUpperCase()
				}
			
			if (validation_type == 'l') // lowercase
				{
					//just change it
					document.contact[i].value = value.toString().toLowerCase()
				}
				
			if (validation_type == 'T') // Title
				{
					//just change it
					//first split value on " "
					string_array = value.toString().split(" ")
					//replace first character of each element with uppercase
					new_value_array = new Array();
					for (x in string_array)
						{
							oneword= string_array[x]
							//alert (string_array[x])
							fletter= oneword.substring(0,1).toUpperCase()
							//alert ("First Letter: " + fletter)
							rest_of_word = oneword.substring(1,oneword.length).toLowerCase();
							//alert ("The Rest: " + rest_of_word)
							new_word= fletter + rest_of_word
							//alert ("New Word: " + new_word)
							new_value_array[x] = new_word
						}
					//join back with " "
					value = new_value_array.join(" ")
					//alert ("New Value: " + value)
					document.contact[i].value = value
				}
			
			
			if (validation_type == 'e') // email
				{
					if (value.indexOf("@") > -1 && value.indexOf(".") > -1 && value.toString().length > 5 && value.indexOf(" ") == -1)
						{}
						else
						{alert_flag = 1; alert_string += label + " must contain a properly formed address.\r";}

				} 
				
			if (validation_type == 'p') // passowrd
				{
					if (value ==  document.contact.again.value && value.toString().length > 0)
						{}
						else
						{alert_flag = 1; alert_string += "Passwords do not match.\r";}

				} 
				
			if (validation_type == 'L') // Literal
				{
					the_split2 = DVcode.split("!!")
    					the_literal = the_split2[1]
    					
    					if (value.indexOf(the_literal) > -1)
						{}
						else
						{alert_flag = 1; alert_string += label + " must contain " + the_literal + ".\r";}

				} 
				
			if (validation_type == 'f') // formated
				{
					non_conforming = 0
					the_split2 = DVcode.split("!!")
    					the_format = the_split2[1]
    					strlength = value.toString().length
    					/* format strings contain the following characters:
    						X represents an alpha character
    						1 represents a numeric character
    						Any other value is literal */
    					//step through each value as a string, evaluating each character
    					//set non_conforming = 1 if there is a problem
    					for (y = 0; y <= the_format.toString().length; y++)
    						{
    							checktype = the_format.toString().substring(y,y + 1)
    							checkval = value.toString().substring(y,y + 1)
    							//alert("Checktype: " + checktype + "\r Checkval: " + checkval)
    							
    							if (checktype == 'X' || checktype == '1') //this is a format character
    								{
    									if(checktype == 'X')
    										{
    											if (parseInt(checkval)){non_conforming = 1}
    										}
    									if(checktype == '1')
    										{
    											if(parseInt(checkval) || checkval == "0")
    												{}
    											else	
    												{non_conforming = 1}
    										}
    								}
    							else	//this is a literal character
    								{
    									if (checktype != checkval) {non_conforming = 1}
    								}
    						}
    					if (non_conforming == 1 && strlength > 0)
						{alert_flag = 1; alert_string += label + " must be of the format " + the_format + ".\r";}

				} 
			
			if (validation_type == 'n') // numeric value
				{
					digits = DVcode.substring(7)
					if (isNaN(value))
						{alert_flag = 1; alert_string += label + " must be a number.\r";}
				} 
			
			if (validation_type == 'c') { // currency (float)

				digits = DVcode.substring(7);

				if (!parseFloat(value)) {
					alert_flag = 1;
					alert_string += label + " must be a number.\r";
				}

			} 
			
			if (validation_type == 's') //social security number
    				{
    					non_conforming = 0
    					the_format = "111-11-1111"
    					//first check length
    					strlength = value.toString().length
    					//if strlength is 9 - then insert '-' at position 4 and 7
    					if (strlength==9) 
    						{
    							part1= value.toString().substring(0,3)
    							part2= value.toString().substring(3,5)
    							part3= value.toString().substring(5,9)
    							//alert("value is " + part1 + "|" + part2 + "|" + part3)
    							value = part1 + "-" + part2 + "-" + part3
    						}
    					
    					/* format strings contain the following characters:
    						X represents an alpha character
    						1 represents a numeric character
    						Any other value is literal */
    					//step through each value as a string, evaluating each character
    					//set non_conforming = 1 if there is a problem
    					for (y = 0; y <= the_format.toString().length; y++)
    						{
    							checktype = the_format.toString().substring(y,y + 1)
    							checkval = value.toString().substring(y,y + 1)
    							//alert("Checktype: " + checktype + "\r Checkval: " + checkval)
    							
    							if (checktype == 'X' || checktype == '1') //this is a format character
    								{
    									if(checktype == 'X')
    										{
    											if (parseInt(checkval)){non_conforming = 1}
    										}
    									if(checktype == '1')
    										{
    											if(parseInt(checkval) || checkval == "0")
    												{}
    											else	
    												{non_conforming = 1}
    										}
    								}
    							else	//this is a literal character
    								{
    									if (checktype != checkval) {non_conforming = 1}
    								}
    						}
    					
    					if (non_conforming == 1 && strlength > 0)
						{alert_flag = 1; alert_string += label + " must be of the format " + the_format + ".\r";}
						else
						{
							//put the value back into the form
						}
						
    				}// end if ssnum
    				
   	if (validation_type == 't') //telephone number
   	
    				{
  					non_conforming = 0
    					the_format = "111-111-1111"
    					//first check length
    					strlength = value.toString().length
    					//if strlength is 10 - then insert '-' at position 4 and 7
    					if (strlength==10) 
    						{
    							part1= value.toString().substring(0,3)
    							part2= value.toString().substring(3,6)
    							part3= value.toString().substring(6,10)
    							//alert("value is " + part1 + "|" + part2 + "|" + part3)
    							value = part1 + "-" + part2 + "-" + part3
    						}
    					
    					/* format strings contain the following characters:
    						X represents an alpha character
    						1 represents a numeric character
    						Any other value is literal */
    					//step through each value as a string, evaluating each character
    					//set non_conforming = 1 if there is a problem
    					for (y = 0; y <= the_format.toString().length; y++)
    						{
    							checktype = the_format.toString().substring(y,y + 1)
    							checkval = value.toString().substring(y,y + 1)
    							//alert("Checktype: " + checktype + "\r Checkval: " + checkval)
    							
    							if (checktype == 'X' || checktype == '1') //this is a format character
    								{
    									if(checktype == 'X')
    										{
    											if (parseInt(checkval)){non_conforming = 1}
    										}
    									if(checktype == '1')
    										{
    											if(parseInt(checkval) || checkval == "0")
    												{}
    											else	
    												{non_conforming = 1}
    										}
    								}
    							else	//this is a literal character
    								{
    									if (checktype != checkval) {non_conforming = 1}
    								}
    						}
    					
    					if (non_conforming == 1 && strlength > 0)
						{alert_flag = 1; alert_string += label + " must be of the format " + the_format + ".\r";}
						else
						{//put the values back into the form
							

						}
							
							
    				}// end if phone

			
			}//end if (field_name.indexOf("~DV")
	}//end for i loop
	
	//display alert
	if (alert_flag == 1) //there was an error
		{
			alert ("Please correct the following problems: \r" + alert_string + "\rVersion: " + version)
			return false
		}
		else 
		{
			return true
		}
		
	}//end checkerr()

