//
// $Id$

function Reload(aEvent) {
	// see http://slashdot.jp/~Motohiko/journal/324775
	var e = aEvent ? aEvent : window.event;
	if( e ){
		// reject when in input fields
		var tag = (e.target || e.srcElement).tagName;
		if( tag == 'TEXTAREA' )
			return;
		
		switch(e.keyCode){
			case 37:    // left arrow
			case 39:    // right arrow
			case 114:    // r key
			case 116:    // F5 ?
				location.href = location.pathname;    //  reload w/o query string
				break;
			case 38:    // up arrow
			case 99:    // c key
				location.href = '?c';    // create
				break;
			case 40:    // down arrow
			case 101:    // e key
				var eid = document.getElementById("eid").value;
				location.href = '?e=' + eid;    // edit
				break;
			case 97:    // a key
				location.href = '?a';    // about
				break;
		}
	}
}

function onLoad() {
	document.getElementById("navi").style.visibility = "hidden";
	setTimeout("onTimeout()", 300);
}

function onTimeout() {
	document.getElementById("navi").style.visibility = "visible";
	window.document.onkeydown = Reload;
}

