<!--


/************************************************************

SEE easy_validate_READ_ME for instructions.

SAVE THIS SNIPPET IN ITS ENTIRETY AS A .js FILE

************************************************************/



// This function is called from the validate function below
// to help validate email fields.
function isEmail(elm) {

	if (elm.value.indexOf("@") != "-1" && elm.value.indexOf(".") != "-1"){

	return true;

	}
	
	else{
	return false;
	}
}



function validate () {

// set failed to false. If failed is false, the form goes through. 
// If failed is true, the form gets stopped
var failed=false;

	// loop through required fields
	// if any bad data are encountered 
	// the correct error message
	// is generated, and failed is set to true
	// to stop form submission
	for (i=0; i<validate.arguments.length ; i++) {



	if(validate.arguments[i].type=="text" || validate.arguments[i].type=="textarea" || validate.arguments[i].type=="password") { 
			if(validate.arguments[i].value==""){
			alert(validate.arguments[i+1]);
			validate.arguments[i].focus();
			failed=true;
			break;
			}
		}
		
		if(validate.arguments[i].name.indexOf("_confirm")!=-1) { 
			if(validate.arguments[i].value != validate.arguments[i-2].value){
			alert(validate.arguments[i+1]);
			validate.arguments[i].focus();
			failed=true;
			break;
			}
		}
		
			
		
		if(validate.arguments[i].type=="select-one" || validate.arguments[i].type=="select-multiple") {

		goodToGo=validate.arguments[i].selectedIndex;
	
		if(goodToGo<0){
		goodToGo=0
		}
			if(goodToGo==0){
			alert(validate.arguments[i+1]);
			validate.arguments[i].focus();
			failed=true;
			break;
			}
		}	
		
		
		
		if(validate.arguments[i].name.indexOf("email")!=-1){
		invalidChars = " /:,;" //variable for invalid email characters	

		atPos = validate.arguments[i].value.indexOf("@",1)//variable with position of "@" in email string

		periodPos = validate.arguments[i].value.indexOf(".",atPos)//variable with position of period in email string
	
		//Test for invalid email characters
		for (x=0; x < invalidChars.length; x++) {
		
			badChar = invalidChars.charAt(x);
			if (validate.arguments[i].value.indexOf(badChar,0) > -1) {
			alert(validate.arguments[i+1]);
			
			
			validate.arguments[i].focus();
			failed=true;
			
				}
		}
		
		
		
		//This works in consort w/the "isEmail() function near the top of the page
		if (isEmail(validate.arguments[i]) == false) {
        
      	alert(validate.arguments[i+1]);

        validate.arguments[i].focus();
        
        failed=true;
		break;
        
        
        }
		
			
		
		//Test for minimum # of chars in email address
		else if (validate.arguments[i].value.length < 5) {
        
        alert(validate.arguments[i+1]);

        validate.arguments[i].focus();
        
        failed=true;
		break;
        
        
        }
		
		//Test to make sure there are at least 2 characters after the period
		else if(periodPos+3 > validate.arguments[i].value.length) {
		
		alert(validate.arguments[i+1]);
			
			
			validate.arguments[i].focus();
			failed=true;
			break;
				
		}	
		
		//Test to make sure there's only one "@" symbol
		else if(validate.arguments[i].value.indexOf("@",atPos+1) > -1) {
		
		alert(validate.arguments[i+1]);
			
			
			validate.arguments[i].focus();
			failed=true;
			break;
				
		}
	
	
	
	
	}
	
	
	i=i+1	
}//close for loop
	
	
	
	
	

		
		if(failed){
		return false;
		}
		else{
		return true;
		}
		

	
}//close function validate()


/************************************************************

SEE easy_validate_READ_ME for instructions.

SAVE THIS SNIPPET IN ITS ENTIRETY AS A .js FILE

************************************************************/


//-->


