/* Power Of 9 Key Press Function
   ------------------------------
   
   Expects to have an array of links defined for it to use...
   Get the key code, translate it to a number which corresponds to an
   array reference.
   
   The function is tied to the document.onkeypress.
   Would like to have this defined in the calling page ideally.

*/

document.onkeypress = 
function powerOf9KeyPress(evt) {
	var c = document.layers ? evt.which 
			: document.all ? event.keyCode
			: document.getElementById ? event.keyCode
			: evt.keyCode;
        
    /* We are using the following codes for the character map.
       0 is 47
       9 is 57
       * is 42
       # is 35
       B is 66 or 98
       H is 72 or 104
       We only try to load a page, if we have a key press that corresponds
       required characters (see above).
    */

    if ( ( c > 46 & c < 58) | c==42 | c==35 ) {
    	/* Debug code. Uncomment the following to see which key has been pressed */
    	// alert('pressed ' + String.fromCharCode(c) + '(' + c + ')');
    	
		var keyIdPressed = String.fromCharCode(c);
		if ( keyIdPressed=="#" ) {
			keyIdPressed = "11"; // * or B is back
		}; 
		if ( keyIdPressed=="*" ) {
			keyIdPressed = "10"; // # or H is home
		};
		/* We check to see if the array value exists before we go there */
		if ( p09Link[keyIdPressed] ) {
			window.location = p09Link[keyIdPressed];
			return true;
		}
	}
	return;

};


