function emailtest(src) {
  var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
  var regex = new RegExp(emailReg);
  return regex.test(src);
}

function createcert() {

  if (document.custinfo.realname.value=="") {
    alert("Please fill in your name");
    document.custinfo.realname.focus();
    return;
  }

  var emailaddr = document.custinfo.emailaddress.value;
  emailaddr = emailaddr.toLowerCase();

  while (emailaddr.indexOf(" ")>-1) emailaddr = emailaddr.replace(" ","");

  if (emailaddr!="") {
    if (!emailtest(emailaddr)) {
      alert("Invalid eMail");
      document.custinfo.emailaddress.focus();
      return 0;
    }
  }

  document.custinfo.emailaddress.value = emailaddr;	// put cleaned value back

  if (document.custinfo.community[0].selected==true) {
    alert("Select which community you are interested in");
    document.custinfo.community.focus();
    return;
  }
  var commun="";
  for (var i=0; i<document.custinfo.community.length; i++) {
    if (document.custinfo.community[i].selected==true) {
      commun=document.custinfo.community[i].text;
    }
  }
  if (commun=="") {
    alert("Please Select a Community");
    document.custinfo.community.focus();
    return;
  }

  document.custinfo.submit();	//send in the info
}
