/*
 * Javascript for checking tests
 *
 * Version 1.0, copyright DESK Spachkurse 2004
 * Created by Ingenieurbuero Thunell [www.thunell.com]
 ******************************************************/

// checks the answers for test 1 (Einstufung Deutsch) or similiar tests
function checkAnswer() {

	var answer = 0;
	
	for (i = 0; i < 4; i++) {
		if (document.question.answer[i].checked) {
			answer = document.question.answer[i].value;
			showResult(i, answer);
		}
	}

	// check if it's the first guess...
	// then we save the value, else ignore
	if (document.question.answered.value == 0) {
		document.question.answered.value = 1;
		
		if (answer == 1) {
			if (!parseInt(document.question.rightAnswers.value))
				document.question.rightAnswers.value = 1;
			else
				document.question.rightAnswers.value = parseInt(document.question.rightAnswers.value) + 1;
		} else {
			if (!parseInt(document.question.wrongAnswers.value))
				document.question.wrongAnswers.value = 1;
			else
				document.question.wrongAnswers.value = parseInt(document.question.wrongAnswers.value) + 1;
		}
	}
}

// shows the face pic sad | happy depending on the answer
function showResult(n, na) {
	// if correct, happy face...
	if (na == 1)
		document.answerPic.src = 'img/antwort-richtig_cu2451w0h0.jpg';
	else
	// if not, sad face...
		document.answerPic.src = 'img/antwort-falsch_cu2452w0h0.jpg';
		
	// & show comment...
	document.question.comment.value = comment[n];
}

// shows the tip for the test 2 & 3 (modal verb & Co.)
function showTip(nr) {
	
	alert(tipArray[nr]);
}

function setTry() {

	document.question.firstTry.value = parseInt(document.question.firstTry.value) + 1;
}
