window.onload = function() {
  var f, u, p, c, l, req;
  if (document.getElementById) {
    u = document.getElementById('txtUserID');
    p = document.getElementById('txtPassword');
    c = document.getElementById('hdnCapabilities');
    l = document.getElementById('hdnLanguage');
    req = document.getElementById('requestAccount');
    if (c) c.value = 'w3c';
  } else if (document.all) {
    u = document.all['txtUserID'];
    p = document.all['txtPassword'];
    c = document.all['hdnCapabilities'];
    l = document.all['hdnLanguage'];
    req = document.all['requestAccount'];
    if (c) c.value = 'ms';
  }
  if (l) {
    l.value = (navigator.language) ? navigator.language : navigator.browserLanguage;
  }
  if (u && !u.value) {
    if (u.focus) u.focus();
  } else if (p && p.focus) {
    p.focus();
  }
  if (req) {
    req.innerHTML = '<a href="RequestAccount.html" title="Request a user account">Request a user account</a>';
  }
  f = document.forms['login'];
  if (f) {
    f.onsubmit = validateForm;
  }
};

function validateForm() {
  var u, p;
  if (document.getElementById) {
    u = document.getElementById('txtUserID');
    p = document.getElementById('txtPassword');
  } else if (document.all) {
    u = document.all['txtUserID'];
    p = document.all['txtPassword'];
  }
  if (u && !u.value) {
    if (u.focus) u.focus();
    return false;
  } else if (p && !p.value) {
    if (p.focus) p.focus();
    return false;
  }
  return true;
};
