function verifyForm (f) {
  var msg = '';
  var missing = '';
  var error = '';

  if (f.brand.selectedIndex == 0) {
    missing += "\n         Brand";
  }

  if (f.inq_type.selectedIndex == 0) {
    missing += "\n         Inquiry Type";
  }

  if (isBlank(f.first_name)) {
	 missing += "\n         First Name";
  }
  if (isBlank(f.last_name)) {
	 missing += "\n         Last Name";
  }

  if (f.contact_method.selectedIndex == 0) {
    missing += "\n         Contact Method";
  } else {
	 var cmvlue = f.contact_method.options[f.contact_method.selectedIndex].value;
	 if (cmvlue == 'email') {
		if (isBlank(f.email_address)) {
		  missing += "\n         Email";
		}
	 } else if (cmvlue == 'phone') {
		if (isBlank(f.daytime_phone) && isBlank(f.evening_phone)) {
		  missing += "\n         Phone Number";
		}
	 } else if (cmvlue == 'fax') {
		if (isBlank(f.fax)) {
		  missing += "\n         Fax Number";
		}
	 }
  }

 
  if (f.inq_type.selectedIndex > 0) {
	 var inqt = f.inq_type.options[f.inq_type.selectedIndex].value;

	 if (inqt == 'catalog') {
		if (isBlank(f.address_1)) {
		  missing += "\n         Address";
		}
		if (isBlank(f.city)) {
		  missing += "\n         City";
		}
		if (f.state.selectedIndex == 0) {
		  missing += "\n         State";
		}
		if (isBlank(f.zip)) {
		  missing += "\n         Zip";
		}
	 }

	 if (inqt == 'ordstatus') {
		if (isBlank(f.customernumber)) {
		  missing += "\n         Customer Number";
		}
		if (isBlank(f.ordernumber)) {
		  missing += "\n         PO Number";
		}
	 }
  }


  if (missing) {
    msg += "________________________________________________\n\n";
    msg += "The form was not submitted because of the \n";
    msg += "following error(s).Please correct and re-submit.\n";
    msg += "________________________________________________\n\n";
	 msg += "The following required field(s) are empty:\n";
	 msg += missing;

	 alert(msg);

	 return false;
  }

  if (!isBlank(f.email_address)) {
	 if (!validEmail(f.email_address.value)) {
		alert("The email address you inserted is not valid. Please check it.");
		return false;
	 }
  }

  return true;
}

function validEmail(s) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(s)) {
	  return true;
	} else {
	  return false;
	}
}

function isBlank (e) {
  var s = e.value;
  if (s && s.length) {
	 for (var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ( ( c != ' ') && (c != '\n') && (c != '\t') ) return false;
	 }
  }

  return true;
}
