      function submitForm(form) {
       if (checkIt(form)) {
         form.submit();
       }
      }

      function checkIt(form) {
      var email = form.email.value;
      var question = form.question.value;
      var lib;
      var field1 = form.field1.value;
      var msg = '';

      if (form.library.selectedIndex >= 0) {
                lib = form.library.options[form.library.selectedIndex].value;
        }

      if (lib == null) {
                lib=form.library.value;;
        }

      if(email.length < 1) {
      if(msg.length > 0)
      msg+=', ';
      msg += 'Email address';
      }

      if(question.length < 1) {
      if(msg.length > 0)
      msg+=', ';
      msg += 'Question';
      }

      if(field1.length < 1) {
      if(msg.length > 0)
      msg+=', ';
      msg += 'Name';
      }

      if (form.field2.selectedIndex == 0) {
      if (msg.length > 0) 
      msg+= ', ';
      msg += 'Edgewood status';
      }

      if (msg != '')
      {
      alert("Please enter the following information:\r\n" + msg);
      return false;
      }

      if(lib.length < 1) {
      alert("The library supplying this form has an error in the form. Please contact them and alert them to the problem\r\n");
      return false;
      }

      if (emailCheck(email, true)) {      
      return true;
      }
      else {
      return false;
      }
      }

function emailCheck (emailStr, alertflag) {

var emailPat=/^(.+)@(.+)$/		
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)

if (matchArray==null) {
        if (alertflag)
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}

var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
     if (alertflag) 
    alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat)

if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
      if (alertflag)
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)

if (domainArray==null) {
      if (alertflag)
	alert("The domain name doesn't seem to be valid.")
    return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
musExp = /.museum/

isMus = domain.search(musExp)

if ( ( (domArr[domArr.length-1].length < 2) || (domArr[domArr.length-1].length > 6) ) ||
	(domArr[domArr.length-1].length == 5) ||
	( (domArr[domArr.length-1].length == 6) && (isMus == -1) ) ) {
	  // the address must end in a two, three, or four letter word or .museum
		if (alertflag) 	
			alert("The address must end in a three or four-letter domain, two-letter country, or .museum.")
	   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
      if (alertflag) 
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!

return true;
}
