// Simple check for valid Email address in string

function valid_email(email_address) {
 if (email_address.length < 7) {return false};
  at_location = email_address.indexOf("@");
  dot_location = email_address.lastIndexOf(".");
  space_location = email_address.lastIndexOf(" ");
 if (at_location == -1 || space_location > 0 || dot_location == -1 || at_location > dot_location ) {return false};
 if (at_location == 0) {return false};
 if (dot_location - at_location < 3 ) {return false};
 if (email_address.length - dot_location < 3) {return false};
 return true
}

//Check for empty or only non visible characters in string

function its_not_visible(string_value) {
 var not_visible = " \n\r\t"

 for (var counter = 0; counter < string_value.length; counter++)
{  current_char = string_value.charAt(counter)
  if (not_visible.indexOf(current_char) == -1) {
   return false
  }
 }
 return true
}

//Submit handler can be extended to many more fields

function submit_handler() {

if( valid_email(document.audio.email.value) ) {
return true
  }
else {
  alert('Please enter a valid email address so I can reply \n Hint: Check for leading or trailing spaces');
document.audio.email.focus() ;
return false
  }
}


