// JavaScript Document
// Create new main array. Good for empty text fields
var txt_name = new Array() 
// Form field names is listed first followed by a descriptive name to be show in the js pop up if left blank
txt_name[0] = new Array("FNAME","First Name");
txt_name[1] = new Array("LNAME","Last Name");
// email validation
function checkEmail(myForm) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm)){
		return (true)
	}
	return (false)
}

// function for the blank text fields: parameter -> which array
function missing_content(){
	// check the regular text fields for empty content
	var j;
	var missing_empty = "";

	// [01] CHECK THE TEXT FIELDS FROM THE ARRAY ABOVE
	for (j=0; j<txt_name.length; j++){
		if (document.contact[txt_name[j][0]].value == "") {
			missing_empty+= txt_name[j][1] + "\n";
		}
	}
	return missing_empty;
}

function validation(){
	var missing = "";
	
	// ck and validate the email address
	email = checkEmail (document.contact["EMAIL"].value);
	
	if (email == false){
		missing+= "Invalid Email Address.\n";
	}
	

	// ck for blank fields
	missing += missing_content("txt_name");
	
	// FINALE: is anything missing?
	if (missing != ""){
		missing_hdr = "The Following Information Is Required:\n";
		alert (missing_hdr + missing);
		return false;
	} else {	
		return true;
	}

}


	