$(function( $ ){
	var current = -1;
	var count = ($('li.link').size())-1;

// Navigating Up/Down/Left/Right by keyboard
	$(document).bind('keydown', 'up', function(){
		rm_highlight();
		if(current>0) current--;
		highlight();
	});
	$(document).bind('keydown', 'down', function(){
		rm_highlight();
		if(current<count) current++;
		highlight();
	});
	
	$(document).bind('keydown', 'space', function(){
		uri=$('li.link:eq('+current+') a:first').attr('href');
		window.location=(uri);
	});
	
	function rm_highlight() {
		($('li.link:eq('+current+')')).removeClass('highlight')
	}
	function highlight() {
		($('li.link:eq('+current+')')).addClass("highlight");
	}
	
	$(document).bind('keydown', 'left', function(){
		prev = $(document.getElementById('prev')).attr('href');
		if(prev) window.location=(prev);
	});
	$(document).bind('keydown', 'right', function(){
		next = $(document.getElementById('next')).attr('href');
		if(next) window.location=(next);
	});
});
