/** Access Keys Javascript File
*
* This file work via the use of and inital array table.
* The script the captures the pressed keys in the site page
* and coverts the key unicode into ascii code so that the
* press key can be compared.
* 
* The pressed key is then compared with the chararcter assignment
* in the array and if there is a match the links is followed.
*
*/


var keyActions = new Array (); //Array Table

keyActions [0] = {character:  "1", 
                  actionType: "link", 
                  param:      "index.html"}; //Home Page
				  
keyActions [1] = {character:  "2", 
                  actionType: "link", 
                  param:      "accessibility.html"}; //Accessibility

keyActions [2] = {character:  "3", 
                  actionType: "link", 
                  param:      "help.html"}; //Help
				  
keyActions [3] = {character:  "4", 
                  actionType: "link", 
                  param:      "privacy_policy.html"}; //Privacy Policy
				  
keyActions [4] = {character:  "5", 
                  actionType: "link", 
                  param:      "site_map.html"}; //Site Map
				  
keyActions [5] = {character:  "6", 
                  actionType: "link", 
                  param:      "opening_hours.html"}; //Opening Hours
				  
keyActions [6] = {character:  "7", 
                  actionType: "link", 
                  param:      "contact_us.html"}; //Contact Us
				  
keyActions [7] = {character:  "8", 
                  actionType: "link", 
                  param:      "core_advice.html"}; //Core Advice
				  
keyActions [8] = {character:  "9", 
                  actionType: "link", 
                  param:      "choice.html"}; //ChoicE				  
				  
keyActions [9] = {character:  "0", 
                  actionType: "link", 
                  param:      "volunteering.html"}; //Volunteering		 
                  

                  
// End of user defined array

function hotKeys (event) {

  // Get details of the event dependent upon browser
  event = (event) ? event : ((window.event) ? event : null);
  
  // We have found the event.
  if (event) {   
    
      // Pick up the Unicode value of the character of the depressed key.
      var charCode = (event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);
      
      // Convert Unicode character to its lowercase ASCII equivalent
      var myChar = String.fromCharCode (charCode).toLowerCase();
          
      // Now scan through the user-defined array to see if character has been defined.
      for (var i = 0; i < keyActions.length; i++) {
         
        // See if the next array element contains the Hotkey character
        if (keyActions[i].character == myChar) { 
      
          // Yes - pick up the action from the table
          var action;
            
          // If the action is a hyperlink, create JavaScript instruction in an anonymous function
          if (keyActions[i].actionType.toLowerCase() == "link") {
            action = new Function ('location.href  ="' + keyActions[i].param + '"');
          }
                    
          // At last perform the required action from within an anonymous function.
          action ();
         
          // Hotkey actioned - exit from the for loop.
          break;
        }
      }
    }
  }
/*============================================================================*/
