//
// Callback function for login form.
//
function submitLogin() {
  // Call the perl function to validate the user's credentials.
  // Pass the username.  The function returns html code if
  // it encounters an error.  Otherwise, it redirects the user.
  checkLoginCB(['username','pwd'], [handleLogin]);
  return(true);
}

//
// Function to handle return values from checkLoginCB.
//
function handleLogin() {
  var flag = arguments[1]
  var error_str = arguments[2];

  // The credentials were valid.  Redirect the user.
  if (flag == 1) {
    var filename = document.getElementById('filename').value;
    window.open(filename, '_self');
  }

  // The credentials were invalid.  Display the error string.
  else {
    var span_e = document.getElementById('error_login');
    span_e.style.display = 'block';
    span_e.innerHTML = error_str;
  }
}
