// JavaScript Document
/* validation of the classifieds form */
// 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("NAME","Name") 
txt_name[1] = new Array("ADDRESS","Mailing Address") 
txt_name[2] = new Array("CITY","City")
txt_name[3] = new Array("ZIP","Zip Code")
txt_name[4] = new Array("EMAIL","Email Address")


// check for blank text fields
function missing_content(){
	// check the regular text fields for empty content
	var j;
	var error_ct=0; // a counter variable for the errors;
	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 for blank fields
	missing = missing_content();
	

	// FINALE: is anything missing?
	if (missing != ""){
		missing_hdr = "The Following Fields Are Required:\n";
		alert (missing_hdr + missing);
		return false;
	} else {	
		return true;
	}
}
