/* ======================================================================
DESC: The functions to use in the multiple option hurdle. Note there is devOptionsChoicetool.htm to produce the supporting material

PLATFORMS: 

USAGE NOTES: 
====================================================================== */

/* ======================================================================
FUNCTION: 	check(n)

use devOptionsTool.htm or devOptionsBasicTool to produce some/all of the following...

INPUT:		n == 0 for wrong answers, == 1,... for correct answers up to the number of correct answers
				
NEEDS TO BE DEFINED:						page	== web page to send to, numCorrect == number of total correct answers

OPTIONAL TO BE DEFINED: 				msgDone == message when finished, msgWrong = message when an incorrect selection is made, action == javascript to be performed 
	finished() for:	if (typeof finished == 'function') finished() (at end)

winOpen() included below...no need to link to cafe...

EXAMPLE:
var page = "Tch2_4Symbolization2.htm"
var numCorrect = 3
function finished() {
winOpen('Qch2_5a.htm')
}

To reset for second option group add something like the following:(see T2.5 p. 5)

var done = false
function redo() {
	if (!done) {
		done = true
		numCorrect = 3
		count = 0
		stat1 = ''
		page="#finished"
	}

ALSO FOR THE PAGE WITH OPTIONS:  onMouseOver="window.status=stat1;return true"
====================================================================== */
var count = 0
var track = new Array
var stat1='';var msgWrong, msgDone
if (typeof alertMsg == "undefined") var alertMsg = new Array
if (typeof relocate == "undefined") var relocate = true
if (msgWrong== null) msgWrong = "No, not that one..."
if (msgDone== null) msgDone = (numCorrect == 1) ? "Yes, that\'s the one!" : "Good, those are all the correct answers."
function check(n) {
if (n==0) {
	stat1=''
	window.status=stat1
	alert(msgWrong)
	}
else if ( n<0 ) {
   n*=-1
   stat1=''
	window.status=stat1
   if ( alertMsg[n]!=null && alertMsg[n]!='' ) alert(alertMsg[n])
}
else {
	if ( track[n] == null ) {track[n] = true;count++}
	if ( alertMsg[n]!=null && alertMsg[n]!='' ) alert(alertMsg[n])
	if (count >= numCorrect ) {
		stat1=''
		window.status=stat1
		alert(msgDone)
		if (typeof finished == 'function') finished()
		if (relocate) location = page
		else eval(action)
		}
	else {
		stat1 = 'CORRECT! That\'s ' + count + ' of ' + numCorrect + '.' 
		setTimeout('window.status = stat1',1);
		}
	}
}

function winOpen(URL,h,w) {
if (typeof h != 'number') h = 500
if (typeof w != 'number') w = 600
var nW = 'newWindow = window.open(URL, "newWin", "scrollbars,resizable,status,height=' + h + ',width=' + w + '")'
eval(nW)
		newWindow.focus()
}  

