function writeIt(m,o) { // m the optional addition to the length of derivation s-elements; o is the added number to be added on the first line; derLength and derWidth need to be defined or they take the defaults.
if (typeof derWidth == 'undefined') derWidth = 1
if (typeof derLength == 'undefined') derLength = 2
for ( var i=1; i<derLength+1; i++ ) {
	var lineNum = (i<10)? '&nbsp;' + i : i
	var sze = 16
	var Jsze = 9
	var Isze
	var sze1 = 0 // the length to be added to the first level sentence inputs
	if (navigator.appName == "Netscape" && navigator.appVersion.indexOf("4")>-1) {
		sze = 8; Jsze = 6
	}
	if (typeof m == 'number') sze+=m
	if (typeof o == 'number') sze1 = o
	document.write('<INPUT TYPE="text" NAME="' + 'j' + i + '" size="' + Jsze + '" onfocus="this.blur()">');
   	document.write('<tt>' + lineNum +'</tt>');
   	for ( var j=1; j<=derWidth; j++ ) {
		Isze = (j==1)? sze + sze1 : sze
   		document.write('<INPUT TYPE="text" NAME="' + 's' + i + j + '" size="' + Isze + '" onfocus="this.blur()">');
   		if ( j==derWidth ) document.write('<br>')
		}
	}
}

function writeSub(x) {//for the 'What if...' field
	sze = (navigator.appName == "Netscape" && navigator.appVersion.indexOf("4")>-1) ? 8 : 16
	if (x=='a') x = "What if ..."
	else if (x=='f') x=''
	else x = "then ......."
	document.write('<INPUT TYPE="text" size="' + sze + '"  value="' + x +'" onfocus="this.blur()">');
}


	var pos = 1,times=0 // these will be changed by check(el)
function focCheck(el) {
var elN = el.name
var elNum = parseInt(el.name.charAt(el.name.length - 1)) //only meant to work on derivations to length 9 after premises
if (elNum != pos  && doneEl.indexOf(elN)==-1 ) {
	var am="Careful, you need to do these in the correct order. Start at the top and work down."
	alert(am);status="Careful with order of your answers." 
	el[0].selected=true;el.blur()
	}
}

	var  doneEl='', curEl=null
function check(el) { 
if ( el[el.selectedIndex].value != '1' ) {
	if (aMsg[el.name + el.selectedIndex]!=null) alert(aMsg[el.name + el.selectedIndex])
	else if ( aMsg[el.name]!=null ) alert(aMsg[el.name])
	else alert('Not that one...try again')
	wrong(el)
	}
else {
	el.blur()
	curEl = el
	if(times==1) {pos++;times=0}
	else times=1
	status='Correct!'
	el.onfocus=blurIt
	if (pos>totalNum) {
		doneEl+=el.name
		var doneX="Great, this quiz is finished.\n\nMake sure you see just how this derivation works before moving on."
		alert(doneX)
		setTimeout('status="Great, this one is done"',100)
		status='Done'
		update()
		}
	}
}

function wrong(el) {
status='Not Correct!'
el[0].selected = true
el.blur()
}

function blurIt() {
curEl.blur()
if (status.charAt(0)!='D') alert('This one is already correct.')
curEl.blur()
}



function nav4() {
status=''
if (navigator.appName.indexOf('Net')>-1 && navigator.appVersion.charAt(0)=='4') document.drop.reset()
}

