function validEmail(theEntry) {
  badEntry = false
  invalidChars = " /:,;"
  if (theEntry == "") { 
    badEntry = true
  }
  for (i=0; i < 5; i++)  {
    badChar = invalidChars.charAt(i)
    if (theEntry.indexOf(badChar,0) > -1) {
      badEntry = true
    }
  }  
  atsignLoc = theEntry.indexOf("@",1)
  if (atsignLoc == -1) {
    badEntry = true
  }     
  if (theEntry.indexOf("@",atsignLoc+1) > -1) {
    badEntry = true
  }
  dotLoc = theEntry.indexOf(".",atsignLoc)
  if (dotLoc == -1) {
    badEntry = true
  }
  if (dotLoc+3 > theEntry.length) {
    badEntry = true
  }
  return badEntry
  
}
function ValidateForm(oForm) {
  var oFocusItem = null; var sMessage = new String;
  var bPassed = true; 
  var oItems = oForm.elements;
  for (var i = 0; i < oItems.length; i++) {
    if ( (oItems.item(i).className.indexOf('requiredfield') > -1) ) {
      if ( oItems.item(i).value.length < 1) { 
        oItems.item(i).className += ' invalidfield';
        if ( !oFocusItem ) oFocusItem = oItems.item(i);
        bPassed = false;
        sMessage = 'Er zijn verplichte velden. Deze graag invullen.';
      } else if ( oItems.item(i).className.indexOf(' invalidfield') > -1) {
        oItems.item(i).className = 'requiredfield';
      }
    }
  }
  if (bPassed && (oForm.email.value.length > 0) && validEmail(oForm.email.value)) {
    oForm.email.className += ' invalidfield';
    oFocusItem = oForm.email;
    sMessage = 'Invalid email.';
    bPassed = false;
  };
  if ( !bPassed ) {
    if ( oFocusItem ) oFocusItem.focus();
    alert(sMessage);
  };
  return bPassed;
}

