// Regualr Expressions For Form
var fullNameRE = /^\w{1,}([ ])\w{1,}$/;
var emailRE = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

var regExLookUpTable = new Array();
	regExLookUpTable.push(fullNameRE);
	regExLookUpTable.push(emailRE);

// Setting Up Alerts For User //
var noFillAlertStart = "Please enter a value for the field labeled";
var validationAlertArray = new Array();
	validationAlertArray.push("Please enter a contact name. (i.e. John Doe)");
	validationAlertArray.push("Please enter valid email address.");

function validateForm(theForm){
	var formOk = true;
	var theTotalElements = (theForm.elements.length)-3;
	for(i=0;i<=theTotalElements;i++){
		var theElementName = theForm.elements[i].name;
		var theElementValue = theForm.elements[i].value;
		var theElementTitle = theForm.elements[i].title;
		if(theElementValue == ""){
			alert(noFillAlertStart + " " + theElementTitle);
			return(false);
		}else{
			var theRegEx = regExLookUpTable[i];
			if(theRegEx != null){
				if(!theRegEx.test(theElementValue)){
					alert(validationAlertArray[i]);
					return(false);
				}
			}
		}
  	
	}	
  if(formOk){
  	return(true);
  }
}

function validateSearch(theSearchForm){
	var theSearchValue = theForm.elements[i].value;
	if(theSearchValue == ""){
		return(false);
	}else{
		return(true);
	}
}
