

nextfield = "next"; // name of first box on page
netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");

function keyDown(DnEvents) { // handles keypress

	// determines whether Netscape or Internet Explorer
	k = (netscape) ? DnEvents.which : window.event.keyCode;
//	debug("Got an Event="+k+" nextfield="+nextfield);

	//Only act on the 'Enter' Key! Ignore all others!
	if (k == 13) { // enter key pressed
		if (nextfield == 'done') return true; // submit, we finished all fields
		
		// For IE Browsers, we can convert the EnterKey to a Tab Key, thus causing
		// the desired effect of tabbing to the next field, despite the fact that nextfield
		// was not known and only set to 'next' !
		if (nextfield == 'next'){
			if(!netscape){
				window.event.keyCode = 9;
				//window.event.cancelBubble=true;
			}
			else
			{
				//Seems to be no way to force Netscape to move to next field!
			}
			return true;
		}
		else { // we're not done yet, send focus to next box
			x=eval(nextfield);
			if(x)eval(nextfield + '.focus()');
			return false;
      }
   }
}

//function fun2(e) {   
//	debug("The document got an event of type: " + e.type + "The KeyCode is:" + e.keyCode);
//	return false;
//}


if (netscape){
	document.captureEvents(Event.KEYDOWN);
}

document.onkeydown = keyDown;

