/********************************************************************
validateFieldArray:
	This function requires all fields and comments
	returned by the validateForm function. It loops
	through the form fields and checks whether it's
	an input type of text or not.  If the user
	left the field blank, it alerts the user
	with the message that was specified in the
	ValidateForm function.
*********************************************************************/

function validateFieldArray( flds ){
 for (var i = 0; i < flds.length; i ++){
  if ( flds[i][2] == "text"){
	  if ( flds[i][0].value == "" ){
	   alert( "Please enter " + flds[i][1] );
	   try {flds[i][3].focus()} catch (e) {try {flds[i][0].focus()} catch (f) {}}
	   return false;
	  }
  }
  else if ( flds[i][2] == "date"){
	  if (isDate(flds[i][0].value)) { } else {
	   alert( "Please enter " + flds[i][1] );
	   try {flds[i][3].focus()} catch (e) {try {flds[i][0].focus()} catch (f) {}}
	   return false;
	  }
  }
  else if ( flds[i][2] == "email" ){
	  var emailFilter=/.+@.+\..{2,3}/;
	  if ( flds[i][0].value == "" || !(emailFilter.test(flds[i][0].value))) {
	   alert( "Please enter " + flds[i][1] );
	   try {flds[i][3].focus()} catch (e) {try {flds[i][0].focus()} catch (f) {}}
	   return false;
	  }
  }
  else if ( flds[i][2] == "zipcode" ){
  	var intCountry = 0
  	try {if (document.form1.Country.length > 0) { intCountry = 1 } } catch (e) {}
  	if (intCountry == 1) {
  	  if (document.form1.Country.options[document.form1.Country.selectedIndex].value == "United States") {
	  	  zipFormat=" in the form 12345 or 12345-6789"
		  zipFilter=/^[0-9]{5}-[0-9]{4}|[0-9]{5}$/;
	  }
	  else {
	  	  zipFormat=""
		  zipFilter=/.{0,10}/;
	  }
	  if ( flds[i][0].value == "" || !(zipFilter.test(flds[i][0].value))){
	   alert( "Please enter " + flds[i][1] + zipFormat );
	   try {flds[i][3].focus()} catch (e) {try {flds[i][0].focus()} catch (f) {}}
	   return false;
	  }
	} else {
  	  zipFormat=" in the form 12345 or 12345-6789"
	  zipFilter=/^[0-9]{5}-[0-9]{4}|[0-9]{5}$/;
	  if ( flds[i][0].value == "" || !(zipFilter.test(flds[i][0].value))){
	   alert( "Please enter " + flds[i][1] );
	   try {flds[i][3].focus()} catch (e) {try {flds[i][0].focus()} catch (f) {}}
	   return false;
	  }
	}
  }
  else if ( flds[i][2] == "select"){
	  if ( flds[i][0].selectedIndex == 0 ){
	   alert( "Please select " + flds[i][1] );
	   try {flds[i][3].focus()} catch (e) {try {flds[i][0].focus()} catch (f) {}}
	   return false;
	  }
  }
  else if ( flds[i][2] == "number"){
	  if ( isNaN(parseInt(flds[i][0].value))){
	   alert( "Please enter " + flds[i][1] );
	   try {flds[i][3].focus()} catch (e) {try {flds[i][0].focus()} catch (f) {}}
	   return false;
	  }
  }
 }
 return true;
}
