// JavaScript Document
arrValidForm01 = new Array(
/* new Array("id of input"			  	,	"plain English name of input"				, "required"),                    */
new Array("contact_name"		      ,	"First Name" 										    , "required"), 		   /* has comma */
new Array("contact_lastname"		  ,	"Last Name" 										    , "required"), 		   /* has comma */
//new Array("contact_cphone"				,	"Cell Phone"										    , "required"),       /* has comma */
//new Array("contact_wphone"				,	"Work Phone"										    , "required"),       /* has comma */
new Array("contact_ephone"				,	"Evening Phone"										  , "required"),       /* has comma */
new Array("contact_email"				  ,	"Email"										          , "required"),       /* has comma */
new Array("contact_address"			  ,	"Address"											      , "required"),       /* has comma */
new Array("contact_city"				  ,	"City"										          , "required"),       /* has comma */
new Array("contact_state"				  ,	"State"										          , "required"),       /* has comma */
new Array("contact_zipcode"				,	"Zipcode"									          , "required"),       /* has comma */
new Array("contact_age"           , "Age"                               , "required"),       /* has comma */
new Array("contact_height"        , "Height"                            , "required"),       /* has comma */
new Array("contact_weight"        , "Weight"                            , "required"),       /* has comma */
new Array("contact_procedure"			,	"Procedure"										      , "required"),       /* has comma */
new Array("contact_time"			    ,	"Time"    										      , "required"),       /* has comma */
new Array("contact_comments"			,	"Questions and Comments"					  , "required") 		   /* the final input should not have a comma */
);

function EK_validateForm(objFormToValidate, arrValidationMain){
	results = "";
	temp = "";
	for (i=0;i<arrValidationMain.length;i++) {
		inputElementToFind = arrValidationMain[i][0];
		if (objFormToValidate[inputElementToFind]) {
			temp=EK_validateElement(arrValidationMain[i], objFormToValidate);
			if(temp) {
				results += temp + "\r\n";
			}
		} else {
			results += "Validation Error: " + "\'" + arrValidationMain[i][0] + "\' Is not an input element in the form " + "\'" + objFormToValidate.name + "\r\n";
		}
	}
	if(results){
		alert(results);
		return false;
	} else {return true}
}

 function EK_validateElement(arrOfValidationArgs, objFormToValidate) {
nameOfElement = arrOfValidationArgs[0];
errorText = arrOfValidationArgs[1];
validationType = arrOfValidationArgs[2];
inputObj = objFormToValidate[nameOfElement];
switch (validationType)
{
   case "required" :
		if (inputObj.defaultValue == inputObj.value) {
			return "The field labeled " + "\'" + errorText + "\'" + " cannot be left empty.";
		}
      break;
   case "required_email" :
		if ( 
				(inputObj.defaultValue == inputObj.value)
				|| (inputObj.value.indexOf("@")<=0)
				|| (inputObj.value.lastIndexOf(".")<3)
				|| (inputObj.value.length<(inputObj.value.indexOf(".")+2))
			) {
			return "The field labeled " + "\'" + errorText + "\'" + " must contain a valid email address.";
		}
      break;
   case "required_zip" :
		if ( 
				(inputObj.defaultValue == inputObj.value)
				|| isNaN(inputObj.value)
				|| (inputObj.value.length != 5)
			) {
			return "The field labeled " + "\'" + errorText + "\'" + " must contain a valid zip code.";
		}
      break;
   case "required_dropdown" :
		if ( 
				inputObj.selectedIndex == 0
			) {
			return "In the field labeled " + "\'" + errorText + "\'" + " you must make a selection.";
		}
      break;
	case "required_phone" :
		numberOfRequiredDigits = 10;
		if(		inputObj.value
				&& (inputObj.defaultValue != inputObj.value)
				&& (inputObj.value.length >= numberOfRequiredDigits)
				) {
			numSring = new String();
			for(x=0; x<inputObj.value.length ; x++) {
				if(!isNaN(inputObj.value.charAt(x)) && (inputObj.value.charAt(x)!=" ")){
					numSring += inputObj.value.charAt(x);
				}
			}
			if (numSring.length == 10){
				inputObj.value =(
									"("
									+ numSring.substring(0,3) + ") "
									+ numSring.substring(3,6) + "-"
									+ numSring.substring(6,10)
								)
			} else {
				return "The field labeled " + "\'" + errorText + "\'" + " must contain a valid 10 digit phone number."
			}
		} else {
			return "The field labeled " + "\'" + errorText + "\'" + " must contain a valid 10 digit phone number."
		}
	break;
   default :
		return "Validation Error: No Validation Type Chosen for " + "\'" + errorText + "\'";
}
}

//-->