var Netscape = false;
var Opera=false;
var Konqueror=false;
if (navigator.userAgent.indexOf('Opera') != -1) Opera=true;
if (navigator.userAgent.indexOf('Konqueror') != -1) Konqueror=true;
if(navigator.appName == "Netscape")  Netscape = true;
var apprx = /^([0-9]+).*/;
var navigatorversion=navigator.appVersion.replace(apprx, "$1");

function key_down(e){
    if (e.which>=37 && e.which<=40){
	key_press(e);
    }
    
}
function key_press(e){
    if (Netscape) {
	if (e.which < 20 && e.which!=13 ) return true;
	var alt = false;
	var shift = false;
	var ctrl = false;
	//if (e.modifiers){
	//    // ns4
	//    if (e.modifiers & Event.ALT_MASK) { alt=true; }
	//    if (e.modifiers & Event.CONTROL_MASK) { ctrl=true; }
	//    if (e.modifiers & Event.SHIFT_MASK) { shift=true; }
	//} else {
	//    // ns 6
	//    if (e.shiftKey) { shift=true; }
	//    if (e.altKey) { alt=true; }
	//    if (e.ctrlKey) { ctrl=true; }
	//}
	window.status='';
	var x=keyaction(e.which, alt, ctrl, shift);
	if (x){
	    // http://www.mozilla.org/docs/dom/domref/dom_event_ref31.html#1004320
	    //if (!e.canelable) window.status='Grmpf, can\' preventDefault';
	    e.preventDefault();
	    e.stopPropagation();
	}
	return x;
    }
    return true;
} 

if (Netscape){
    /* ns6 can capture Arrow-keys */
    /* but repeat doesn't work with arrow-keys */
    var el=document;
    el.addEventListener("keydown", key_down, false);
    /* capture rest */
    window.captureEvents(Event.KEYPRESS);
    window.onkeypress = key_press;
}

