 // returns true if string contains only whitespace or is empty
function isBlank(s) {
  if (s == null) return true;
  if (s == "") return true;
  for(var i=0; i < s.length; i++) {
    var c = s.charAt(i);
    if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
  }
  return true;
}

function validate(f) {
  if (isBlank(f.cName.value) || isBlank(f.cEmail.value) || isBlank(f.cText.value)) {
    var msg = "Your comment was not submitted for the following reason(s):";
    if (isBlank(f.cName.value))
      msg += "\n * No name";
    if (isBlank(f.cEmail.value))
      msg += "\n * No e-mail address";
    if (isBlank(f.cText.value))
      msg += "\n * Nothing was written";
    alert(msg);
    return false;
  } else {
    return true;
  }
}

