function OnLoginLoad()
{
  try { document.getElementById('UserLogin').focus() } catch (e) { };
}

function OnLoginClick()
{
  var
    sUserLogin, sUserPassword, oCb, bCookieLogin, sUserPasswordMd5;
    
  sUserLogin = document.getElementById('UserLogin').value;
  sUserPassword = document.getElementById('UserPassword').value;
  oCb = document.getElementById('CookieLogin');
  bCookieLogin = (oCb == null ? false : oCb.checked);
  sUserPasswordMd5 = (sUserPassword == '' ? '' : guid_md5(sUserPassword));
  try
  {
    AjaxPost('../desktop/login-db.asp', sUserLogin + '\t' + sUserPasswordMd5 + '\t' + Number(bCookieLogin));
  }
  catch (e)
  {
    alert('There was a problem logging in.\r\n\r\n' +
          'This system requires AJAX support from your browser, with security settings allowing its use.\r\n' +
          'Please ensure your security settings allow ActiveX (click Tools, Internet Options, Security, Custom level), or alternatively, add this site to the "Trusted sites" zone.\r\n\r\n' +
          'The error message was: ' + e.message);
  }
}

function OnLoginDeny()
{
  var
    oUserPassword;
    
  alert('The system could not log you in.\r\n\r\n' +
        'Please ensure your User name and Password are correct.\r\n\r\n' +
        'NB: your password is case-sensitive.');
  oUserPassword = document.getElementById('UserPassword');
  oUserPassword.focus();
  try { oUserPassword.createTextRange().select(); } catch (e) { }
}

function OnLoginError()
{
  alert('An error occurred while logging in.\r\n\r\nPlease advise the Administrator.');
}

function OnLoginAccept(nKey)
{
  SetGlobalCookie('suli', nKey)
  ReloadSelf();
}

