// JavaScript Document

//function autofocus(field, limit, next, evt){
function autofocus(field, limit, next, evt){
	//alert("starting autofocus");
	evt=(evt)?evt:event;
	var theForm = field.form, z = 2;
	var charCode =(evt.charCode) ? evt.charCode : ((evt.keyCode)? evt.keyCode : ((evt.which) ? evt.which : 0));
	if (charCode > 31 && field.value.length == limit) {
		var z=2;
		//alert(next + " " + theForm[z].name);
		//field.form.elements[next].focus();
		//field.form.elements[next].focus();
		//alert("Trying the autofocus thingy");
		//var theForm = theElement.form, z = 15;
	 	while ( z<50) {
		//alert ("trying to find somdthing");
		if (theForm[z].name == next){
			//alert("found one");
			theForm[z].focus();
			break;
		}
		//field[z].checked = theElement.checked;
		z++;
	 }
	}
}

