function clearField(field) {
	if (field.value == field.defaultValue) {
		field.value = "";
	}
}

function isEmail(string) {
    return (string.search(/^\w+((-\w+)|(\.\w+)|('\w+))*\@[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)+$/) != -1);
}

function trim(string) {
// removes spaces at the beginning of a string
    string = string.replace(/^\s*/, "");
// removes spaces at the end of a string
    string = string.replace(/\s*$/, "");

    return string;
}

function isBlank(s) {
  if (s==null) {return true;}
  for (var i = 0; i < s.length; i++) {
    var c = s.charAt(i);
    if ((c != ' ') && (c != '\n') && (c != '\r')) return false;
  }
  return true;
}

function checkEmail(form) {
  if (isBlank(form.email.value)) {
    alert("Please enter your e-mail address.");
    form.email.focus();
    return false;
  }
  else {
    // remove ALL spaces
    form.email.value = trim(form.email.value);
  }
  if (isEmail(form.email.value) == false) {
    alert("'"+form.email.value+"' is not a valid e-mail address.\n"+
          "Please enter a valid e-mail address.");
    form.email.focus();
    return false;
  }
}

// ]]>

