function getcijfer(){
// deze functie vraagt de waarde in de cesuur tabel op bij en gegeven aantal goed
// beantwoorde vragen 

	goed = document.forms[0].aantalpunten.value;
	
	if (goed != "" && goed >= 0 && goed <= 50){
	
		totalscore1 = cesuur2223[goed];
		totalscore2 = cesuur2324[goed];
		totalscore3 = cesuur2425[goed];
		totalscore4 = cesuur2526[goed];
		totalscore5 = cesuur2627[goed];
		totalscore6 = cesuur2728[goed];
		totalscore7 = cesuur2829[goed];
		totalscore8 = cesuur2930[goed];
		totalscore9 = cesuur3031[goed];
		totalscore0 = cesuur3132[goed];
		
		window.alert("Je cijfer is dan, afhankelijk van de cesuur:\n\n\tCesuur\tCijfer\n\t* 22-23\t" + totalscore1 + "\n\t* 23-24\t" + totalscore2 + "\n\t* 24-25\t" + totalscore3 + "\n\t* 25-26\t" + totalscore4 + "\n\t* 26-27\t" + totalscore5 + "\n\t* 27-28\t" + totalscore6 + "\n\t* 28-29\t" + totalscore7 + "\n\t* 29-30\t" + totalscore8 + "\n\t* 30-31\t" + totalscore9 + "\n\t* 31-32\t" + totalscore0 + "\n" );
		return false;
	}
	window.alert("incorrecte waarde!");
}

function getaantal(){
//deze functie geeft het aantal vragen dat de kandidaat minimaal goed moet beantwoorden
//om het gevraagde cijefr te behalen. Als het gevraagde cijfer niet in de tabel voorkomt
//het eerstvolgende hogere cijfer gegeven.

	aantal = document.forms[1].aantalpunten.value;

	if (aantal != "" && aantal <= 10 && aantal >= 1){

		//zorg ervoor dat Javascript door heeft dat het hier om een getal gaat niet om een string
		//en vang af dat 10.0 niet wordt afgerond naar een een of andere vage waarde...
		
		aantal = Math.floor (10*aantal) / 10;
		document.forms[1].aantalpunten.value = aantal;
			
		totalscore1 = searchCesuur(cesuur2223);
		totalscore2 = searchCesuur(cesuur2324);
		totalscore3 = searchCesuur(cesuur2425);
		totalscore4 = searchCesuur(cesuur2425);
		totalscore5 = searchCesuur(cesuur2627);
		totalscore6 = searchCesuur(cesuur2728);
		totalscore7 = searchCesuur(cesuur2829);
		totalscore8 = searchCesuur(cesuur2930);
		totalscore9 = searchCesuur(cesuur3031);
		totalscore0 = searchCesuur(cesuur3132);

		window.alert("Je moet voor een " + aantal + " minimaal \n\n\tCesuur\tAantal\n\t* 22-23\t" + totalscore1 + "\n\t* 23-24\t" + totalscore2 + "\n\t* 24-25\t" + totalscore3 + "\n\t* 25-26\t" + totalscore4 + "\n\t* 26-27\t" + totalscore5 + "\n\t* 27-28\t" + totalscore6 + "\n\t* 28-29\t" + totalscore7 + "\n\t* 29-30\t" + totalscore8 + "\n\t* 30-31\t" + totalscore9 + "\n\t* 31-32\t" + totalscore0 + "\n\nvragen goed hebben, afhankelijk van de cesuur.");		
		
	}
	else{
		window.alert("incorrecte waarde!");
	}
}

function searchCesuur(selectedCesuur){

	for (i=0; i <= selectedCesuur.length; i++){
	//doorzoek de hele cesuur tabel. volgens de gestelde grenzen.
	
		if (aantal <= selectedCesuur[i]){
			return i;
		}
	}
	return NaN;
}

