/*=========================================================
  UNIVERSITY ARCHIVES
  
  Coded by: Rob Ballou
  Last updated: 11.20.02
===========================================================*/
window.onload=init;

function init(){
  document.onkeypress=uaKeyPress;

}

/*
 uaKeyPress()
 
 Keypress event handler for University archives.
 Update the keyMap array to change where the keys
 are mapped to.
*/
var keyMap = new Array(new KeyMap(24, "staff/"),
                       new KeyMap(24, "staff/"));
function uaKeyPress(e){
  var key = getKeyCode(e);
  //alert(key);
  
  // Check if the "CTRL" key is held down
  if(!checkKeys(e))
return;
  
  // Map the key
  for(var i=0; i<keyMap.length; i++){
    if(keyMap[i].key == key){
      document.location = keyMap[i].url;
    } 

}
}

/*
  checkKeys()
  
  Checks if the "CTRL" key was held down
*/
function checkKeys(e){
  if(e){
    if(e.ctrlKey)
      return true;
    else 
      return false;
  }
  else {
    
return true;
  }
}

/*
  getKeyCode()
*/
function getKeyCode(e){
  if(e)
    
return e.which;
  else
    return window.event.keyCode;
}

/*
  KeyMap class
*/
function KeyMap(key, url){
  this.key = key;
  this.url = url;
}

