var gTotalAnsweredCorrectly = 0;
var gTotalAnsweredIncorrectly = 0;

function evaluateAnswer()
{
	// do not evaluate answer unless test has officially started
	if (gTestStarted == "false")
		return;
	
	// determine answer type (text or notes)
	var StaffAnswer = problemArray[ problemToUseArray[gProblemsTakenSoFar] ].StaffAnswer;  // comma deliminated answer, ie c4,e4,g4
	
	var bCorrect = "true";
	if (StaffAnswer.length > 0) // compare Notes on Staff with answer key
	{
	// not finished, xxx to do
		
	}
	else // compare text entry with answer key
	{
		var TextAnswer = problemArray[ problemToUseArray[gProblemsTakenSoFar] ].TextAnswer; // answer key
		
		var theTextAnswer = document.getElementById('theTextAnswer'); // textfield on GUI
		var theTextAnswerValue = theTextAnswer.value;
		theTextAnswerValue = theTextAnswerValue.toLowerCase();
		if (theTextAnswerValue == TextAnswer) // need to trim() the inputted answer, to do later
		{
			gTotalAnsweredCorrectly++;
		}
		else
		{
			gTotalAnsweredIncorrectly++;
		}
		
		// clear textfield
		theTextAnswer.value = "";
		
		// clear notes on staff	
		removeAllNotes();
		
		// clear notes added to NotesArray
		emptyArray();	
	}
	
	//if (gTimed == 'true')
	{
		var percentaccurate = document.getElementById('percentaccurate');
		percentaccurate.innerHTML = Math.round(100*(gTotalAnsweredCorrectly/(gTotalAnsweredCorrectly+gTotalAnsweredIncorrectly))) ;
		
		var percentcomplete = document.getElementById('percentcomplete');
		percentcomplete.innerHTML = Math.round(100*  (gTotalAnsweredCorrectly+gTotalAnsweredIncorrectly)/gTotalOnTest);
	}
	
	gProblemsTakenSoFar++;
	
	// call next problem
	if (gProblemsTakenSoFar < gTotalOnTest)
	{
		showNextProblem();
	}
	else // save the test and show results to student
	{
		// hide the submit button
		var submitButton = document.getElementById('submitButton');
		submitButton.style.display = "none";
		
		// hide the input text field
		var theTextAnswer = document.getElementById('theTextAnswer');
		theTextAnswer.style.display = "none";
		
		// show the final text in the instructions location
		var now = new Date();
		document.getElementById('theInstructions').innerHTML = gFinalInstructionsToStudent + "<br>" + "<a href='index.html' style='cursor:pointer;'><u><b>click here to try again</b></u></a><br>" + now.toLocaleString();
		
		if (gTimed == 'true')
		{
			// stop countdown timer
			window.clearInterval(gCountDownTimer);
			
			// stop the test timer
			window.clearTimeout(gTestTimer);	
		}
	}
	
}


// call to evaluate answer when an enter key is pressed.
function checkyForEnter(event)
{
	if (event.keyCode == 13)
	{
	if (document.all)
		evaluateAnswer(); // only run for IE, Mozilla always submits the form
	}
}



