// Email Validation Javascript
// copyright 23rd March 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n You must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n The email address you supplied contains invalid characters.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert(" - - - - - - - E R R O R  - - - - - - -  \n\n The email address you supplied contains non ascii characters.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n A valid email address must contain an @.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
if (atPos == 0) {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n A valid email address must not start with @.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n A valid email address must contain only one @.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n A valid email address must contain a period in the domain name.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n period must not immediately follow @ in email address.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n period must not immediately precede @ in email address.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n two periods must not be adjacent in email address.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert(' - - - - - - - E R R O R  - - - - - - -  \n\n invalid primary domain in email address.\n\nYou must supply a valid email address to utilize this State Bank of Herscher Website feature.  \n\n Press OK to add your EMail address to this Message.');
   return false;
}
return true;
}

