
function ValidateForm()
{
  field = document.c_login.username;
  if (isBlank(field, "Username")) return false;

  field = document.c_login.password;
  if (isBlank(field, "Password")) return false;
}

function trimLeft(s) {
  var whitespaces = " \t\n\r";
  for(n = 0; n < s.length; n++) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n > 0) ? s.substring(n, s.length) : s; }
  return("");
}

function trimRight(s){
  var whitespaces = " \t\n\r";
  for(n = s.length - 1; n  > -1; n--) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n < (s.length - 1)) ? s.substring(0, n+1) : s; }
  return("");
}

function trim(s) {return ((s == null) ? "" : trimRight(trimLeft(s))); }

function isBlank(field, strFieldName) {
  strTrimmed = trim(field.value);
  if (strTrimmed.length > 0 ) return false;
  alert("\"" + strFieldName + "\" is a required field. Please fill it out.");
  field.focus();
  return true;
}
