/*
 * This file contains the script for processing key events.
 */
(function ($) {
    $.registerKeyHandler = function( l, r, s )
    {
        $(document).keydown( function( e ) 
        {
        	var id = "";
        	
        	// Left and right arrow and space are used for navigation
        	// Left arrow follows the link with the id "left"
        	// Right arrow and space follow the link with the id "right"
        	switch( e.keyCode )
        	{
        		case 37: id = l; break; // left arrow
        		case 39: id = r; break; // right arrow
        		case 32: id = s; break; // space
        	}
        	
        	var goTo = $( "#" + id ).attr( "href" );
        	
        	if( goTo )
        	{
        	    document.location = goTo;
        	}
        } );
    };
})(jQuery);