var reNonBlank=/[\S]/;
var reEMail=/^\w[\w\-\.]+\@\w[\w\-]+(\.[\w\-]+)+$/;

function _checkIt(re, field, msg) {
  if (typeof(field.length)!="undefined") {
    if (field.length==0) {
      return true;
    }
    if (typeof(field.options)!="undefined") {
      if (re.test(field.value)) {
        return true;
      }
    }
    else {
      for (var i=0; i<field.length; i++) {
        if (field[i].checked) {
          return true;
        }
      }
    }
  }
  else {
    if (field.type=="checkbox" || field.type=="radio") {
      if (field.checked) {
        return true;
      }
    }
    else if (re.test(field.value)) {
      return true;
    }
  }

  alert(msg);
  if (typeof(field.select)!="undefined") {
    field.select();
  }
  if (typeof(field.focus)!="undefined") {
    field.focus();
  }

  return false;
}
function goodEMail(field, msg) {
  return _checkIt(reEMail, field, msg);
}
function nonBlank(field, msg) {
  return _checkIt(reNonBlank, field, msg);
}