﻿function LogonActivation() {
  this.ActivationSequence = 'logon';
  this.LogonSequencePressed = '';
  this.LogonFormURL = '/admin/logon.fs'; //  '/users/LogonWindow.fs';
  this.LogonWindowWidth = 300;
  this.LogonWindowHeight = 150;
  this.LogonWindowTitle = 'Log-In';
}

function DetectAndActivateLogonForm(e) {
  var kCode = e ? e.which : window.event.keyCode;
  var char = String.fromCharCode(kCode);
  //a key within the logon sequence was pressed
  if (laProperties.ActivationSequence.indexOf(char) >= 0) {
    laProperties.LogonSequencePressed += char;
    if (laProperties.ActivationSequence.indexOf(laProperties.LogonSequencePressed) >= 0) {
      //see if full sequence pressed
      if (laProperties.ActivationSequence == laProperties.LogonSequencePressed) {
        //WindowOpen(url, title, width, height, clientCloseFunction, maximized, winName, status)
        WindowOpen(laProperties.LogonFormURL, laProperties.LogonWindowTitle, laProperties.LogonWindowWidth, laProperties.LogonWindowHeight, null, false, '', '');
        laProperties.logonSequencePressed = '';
      }
    } else {
      //clear - sequence not followed
      laProperties.LogonSequencePressed = '';
    }
  }
}

//init
var laProperties = new LogonActivation;
document.onkeypress = DetectAndActivateLogonForm;
