var sC = function (d) {
	var command = '';
	var size = 0
	var shortcuts = [];
	var delay = d;
	
	var evaluate = function() {
		if (size === command.length) {
		  execute();
		  command = '';
		} else {
			setTimeout(function() { evaluate(); }, delay);
		}
		size = command.length;
	}
	
	var execute = function() {
	  for (var i in shortcuts) {
	  	if (shortcuts[i].cmd.match("^"+command)) {
	  		shortcuts[i].func.apply();
	  	}
	  }
	}
	
	var registerShortcut = function(cmd, func) {
		shortcuts[shortcuts.length] = {'cmd': cmd.toUpperCase(), 'func': func};
	}
	
	var gotoLink = function(a) {
		return function() {	location.href = (typeof a) === 'string' ? a : a.href; };
	}
	
	
	var loadShortcuts = function() {
		var el = document.getElementsByTagName('a');
		for (var i in el) {
			if (el[i].innerHTML !== undefined && el[i].href !== undefined) {
				registerShortcut(el[i].innerHTML, gotoLink(el[i].href));
			}
			if (el[i].title !== undefined && el[i].href !== undefined) {
				registerShortcut(el[i].title, gotoLink(el[i].href));
			}
		}
	}
	
	var shortcut = function(e) {
	  if (!e) var e = window.event;
	  var src = e.srcElement || e.target;
	  
	  if (src.tagName === 'TEXTAREA' || src.tagName == 'INPUT') {
	  	return;
	  }
	  
	  var code;
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		
	  if ((code >= 65 && code <= 90) || code === 32) {
	  	command += String.fromCharCode(code)
	    if (command.length === 1) {
	    	evaluate();
	    }
	  }
	}
	
	loadShortcuts();
	document.onkeyup = shortcut;
	
	return;
}

if (window.addEventListener) {
	window.addEventListener('load', function() { sC(400)}, false); 
} else if (window.attachEvent) {
	window.attachEvent('onload', function() { sC(400)});
} else {
	window.onload = function() { sC(400)};
}
