	
function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   refocus();
  
   return false;
}
if (addr == '') return true;
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('Your E-Mail Address has invalid characters. Use only valid characters.');
	  document.getElementById('ordEmailAddress').focus();
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert('Your E-Mail Address exceeds the maximum size allowed.');
	 document.getElementById('ordEmailAddress').focus();
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('Your E-Mail Address must include a @.');
    document.getElementById('ordEmailAddress').focus();
   return false;
}
if (atPos == 0) {
   if (db) alert('Your E-Mail Address cannot start with an ampersand.');
   document.getElementById('ordEmailAddress').focus();
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('Your E-Mail Address has a @ in the wrong position.');
    document.getElementById('ordEmailAddress').focus();
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('Your E-Mail Address has a . in the wrong wrong position.');
   document.getElementById('ordEmailAddress').focus();
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('Your E-Mail Address cannot have a . immedately after a @.');
    document.getElementById('ordEmailAddress').focus();
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('Your E-Mail Address cannot have a . immedately before a @.');
   document.getElementById('ordEmailAddress').focus();
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('Your E-Mail Address has a double period.');
    document.getElementById('ordEmailAddress').focus();
   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('Your E-Mail Address uses an improper suffix at the end of the address.');
   document.getElementById('ordEmailAddress').focus();
   return false;
}

return true;
}
