function checkAnswer(){
	
	correct= document.getElementById('correct').innerHTML

	incorrect= document.getElementById('incorrect').innerHTML
	
	var question= document.getElementById('question').innerHTML
	
	if (question.length >48) {
		var lbr= '<br />'
	}
	else {
		var lbr= '<br /><br />'
	}
	
	if (question.indexOf('L') === 0){
		question= '?'
	}

	var solution= document.getElementById('solution').innerHTML
	
	var answer= document.getElementById('typedfield').value
	
	
	if (/^-?\d+$/.test(answer) === true){
		if (answer == solution){
			
			document.getElementById('review').innerHTML= 'Vorige vraag:<br>' + question + solution + lbr + '<span class="correct2">Je antwoord was goed.</span>'
			
			correct++
			
			document.getElementById('correct').innerHTML= correct
		}
		else {
			document.getElementById('review').innerHTML= 'Vorige vraag:<br>' + question + solution + lbr + '<span class="incorrect2">Je hebt foutief geantwoord: ' + answer + '</span>'
			
			incorrect++
			
			document.getElementById('incorrect').innerHTML= incorrect
		}
	}
	else if (answer.length > 0) {
		document.getElementById('review').innerHTML= 'Fout: het antwoord bevatte niet-numerieke lettertekens.'
	}
	
	else {
		document.getElementById('review').innerHTML= 'Fout: het ingevoegde antwoord was leeg.'
	}

// Plaats score cookie

	var correct= document.getElementById('correct').innerHTML
	var incorrect= document.getElementById('incorrect').innerHTML
	var scorestring= correct + '_' + incorrect
	setCookie('score', scorestring, year, '/calc/')
	
	getQuestion()
	
//wis vorig antwoord	
	
	document.getElementById('typedfield').value= ''
	document.getElementById('typed').innerHTML= ''
	
}



var xmlHttp

function getQuestion()
{ 
document.getElementById('question').innerHTML= 'Laden...'
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="/calc/questions.php"
url=url+"?sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {   
 var x= xmlHttp.responseText
 x= x.split('_')
 
 document.getElementById("question").innerHTML= x[0]
 document.getElementById("solution").innerHTML= x[1]
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}