<!-- 
/* Notes - 

This is the master validations file by Tim O'Connell
Last Updated 11/23/2005

Call these functions using the following

<script language="JavaScript" src="http://www.thoughtfunnel.com/js/formvalidations.js" type="text/javascript"></script>

function ckForm(){
	var okForm;
	okForm = false;
	
	var l_arFF = new Array();

	l_arFF[0] = "First_Name";
	l_arFF[1] = "Last_Name";
	l_arFF[2] = "Annual_Salary_Expectations";

	okForm = ckRequired(l_arFF);
	
	okForm = okForm && ckEmail("Email");  
	okForm = okForm && matchEmail("Email", "Email1");
	okForm = okForm && ckPhone("Phone1");
	okForm = okForm && ckRange("Annual_Salary_Expectations", 10000, 999,999);
	return(okForm);
}	

*/

// Begin FormValidations scripts

function ckRequired(p_arFormFields){

	var okForm;
	okForm = true;
	
	var l_sMessage;
	l_sMessage = "The following fields are required: ";
	
	var l_arFF;
	l_arFF = eval(p_arFormFields);
	
	var i;
	for(i = 0; i < l_arFF.length; i++){
		okForm = okForm && ckBlank(l_arFF[i]);
		if(ckBlank(l_arFF[i]) == false){
			l_sMessage = l_sMessage + "\n" + " - " + l_arFF[i].replace("_", " ");			
		}
	}	
	if (okForm == false){
		alert(l_sMessage);
		return(false);
	}else{
		return(true);
	}
}	

function ckBlank(formfield){
	var okBlank;
	okBlank = false;
	
	var l_sFormField;
	l_sFormField = "document.form1." + formfield + ".value";
		
	if (eval(l_sFormField) != ""){
		okBlank = true;
	}else{
		okBlank = false;
	}
	return(okBlank);
}

function ckBlankOB(formfield){
// This funtion is designed to be invoked with "onBlur"
// so that it will immediately call attention the field
// onBlur="ckBlankOB(this);"
// formfield is an object reference in this function

	if (formfield.value != ""){
		okBlank = true;
	}else{
		okBlank = false;
		alert("The field " + formfield.name.replace("_", " ") + " is required.");
		//formfield.focus(); - causes an infinite loop if 2 fields in a row are blank - don't do it.
	}
}

function ckEmail(formfield){
	var okEmail;
	okEmail = false;

	var exp1;
	exp1 = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	
	var l_sFormField;
	l_sFormField = "document.form1." + formfield + ".value";
         
	if (exp1.test(eval(l_sFormField)) == true){
		okEmail = true;
	} else {      
		okEmail = false;
		alert("Please enter a valid e-mail address.");
    }
    return(okEmail);
}

function matchEmail(formfield1, formfield2){
	var okMatch;
	okMatch = false;
	
	var l_sFormField1;
	l_sFormField1 = "document.form1." + formfield1 + ".value";
	
	var l_sFormField2;
	l_sFormField2 = "document.form1." + formfield2 + ".value";

	if (eval(l_sFormField1) == eval(l_sFormField2)){
		okMatch = true;
	}else{
		okMatch = false;
	alert("The e-mail addresses you entered do not match.");
	}
	return(okMatch);
}

// End pageFunctions scripts

-->
