PASS_MARK = 75;
RESULT_PASS = "Congratulations! You passed the Test.\n\n";
RESULT_FAIL = "Sorry please try again.\n\n";
ERROR_MSG = "\nPlease select the appropriate option(s) in the section(s), and then click Score button again.";

QUESTION = new Array(20);
QUESTION[0] = "Question 1";
QUESTION[1] = "Question 2";
QUESTION[2] = "Question 3";
QUESTION[3] = "Question 4";
QUESTION[4] = "Question 5";
QUESTION[5] = "Question 6";
QUESTION[6] = "Question 7";
QUESTION[7] = "Question 8";
QUESTION[8] = "Question 9";
QUESTION[9] = "Question 10";
QUESTION[10] = "Question 11";
QUESTION[11] = "Question 12";
QUESTION[12] = "Question 13";
QUESTION[13] = "Question 14";
QUESTION[14] = "Question 15";
QUESTION[15] = "Question 16";
QUESTION[16] = "Question 17";
QUESTION[17] = "Question 18";
QUESTION[18] = "Question 19";
QUESTION[19] = "Question 20";

flag = new Array(20);

// Reset flags
function init() {
	for (i=1; i<20; i++){
		flag[i] = false;
	}
}

// Question 0 
function question0_set(val) {
	document.forms.calc.point_question0.value = val;
	flag[0] = true;
	//calculate();
}

// Question 1 
function question1_set(val) {
	document.forms.calc.point_question1.value = val;
	flag[1] = true;
	//calculate();
}

// Question 2 
function question2_set(val) {
	document.forms.calc.point_question2.value = val;
	flag[2] = true;
	//calculate();
}

// Question 3 
function question3_set(val) {
	document.forms.calc.point_question3.value = val;
	flag[3] = true;
	//calculate();
}

// Question 4 
function question4_set(val) {
	document.forms.calc.point_question4.value = val;
	flag[4] = true;
	//calculate();
}

// Question 5 
function question5_set(val) {
	document.forms.calc.point_question5.value = val;
	flag[5] = true;
	//calculate();
}

// Question 6 
function question6_set(val) {
	document.forms.calc.point_question6.value = val;
	flag[6] = true;
	//calculate();
}

// Question 7 
function question7_set(val) {
	document.forms.calc.point_question7.value = val;
	flag[7] = true;
	//calculate();
}

// Question 8 
function question8_set(val) {
	document.forms.calc.point_question8.value = val;
	flag[8] = true;
	//calculate();
}

// Question 9 
function question9_set(val) {
	document.forms.calc.point_question9.value = val;
	flag[9] = true;
	//calculate();
}

// Question 10 
function question10_set(val) {
	document.forms.calc.point_question10.value = val;
	flag[10] = true;
	//calculate();
}

// Question 11 
function question11_set(val) {
	document.forms.calc.point_question11.value = val;
	flag[11] = true;
	//calculate();
}

// Question 12 
function question12_set(val) {
	document.forms.calc.point_question12.value = val;
	flag[12] = true;
	//calculate();
}

// Question 13 
function question13_set(val) {
	document.forms.calc.point_question13.value = val;
	flag[13] = true;
	//calculate();
}

// Question 14 
function question14_set(val) {
	document.forms.calc.point_question14.value = val;
	flag[14] = true;
	//calculate();
}

// Question 15 
function question15_set(val) {
	document.forms.calc.point_question15.value = val;
	flag[15] = true;
	//calculate();
}

// Question 16 
function question16_set(val) {
	document.forms.calc.point_question16.value = val;
	flag[16] = true;
	//calculate();
}

// Question 17 
function question17_set(val) {
	document.forms.calc.point_question17.value = val;
	flag[17] = true;
	//calculate();
}

// Question 18 
function question18_set(val) {
	document.forms.calc.point_question18.value = val;
	flag[18] = true;
	//calculate();
}

// Question 19 
function question19_set(val) {
	document.forms.calc.point_question19.value = val;
	flag[19] = true;
	//calculate();
}



// Calculate Total Score
function calculate() {
	total  = Number(document.forms.calc.point_question0.value);
	total += Number(document.forms.calc.point_question1.value);
	total += Number(document.forms.calc.point_question2.value);
        total += Number(document.forms.calc.point_question3.value);
	total += Number(document.forms.calc.point_question4.value);
	total += Number(document.forms.calc.point_question5.value);
	total += Number(document.forms.calc.point_question6.value);
	total += Number(document.forms.calc.point_question7.value);
	total += Number(document.forms.calc.point_question8.value);
	total += Number(document.forms.calc.point_question9.value);
	total += Number(document.forms.calc.point_question10.value);
	total += Number(document.forms.calc.point_question11.value);
	total += Number(document.forms.calc.point_question12.value);
	total += Number(document.forms.calc.point_question13.value);
	total += Number(document.forms.calc.point_question14.value);
	total += Number(document.forms.calc.point_question15.value);
	total += Number(document.forms.calc.point_question16.value);
	total += Number(document.forms.calc.point_question17.value);
	total += Number(document.forms.calc.point_question18.value);
	total += Number(document.forms.calc.point_question19.value);
	
	


	document.forms.calc.point_quiz.value = total;

	error = "";

	for (i=1; i<20; i++){
		if ( !flag[i] ) {
			error += "You did not fill in an answer for " + QUESTION[i] + ".\n";
		}
	}
	
	//alert(error);
	if (error != "")
	{
		error += ERROR_MSG;
		document.forms.calc.result.value = error;
		return;
	}

	if(total >= PASS_MARK)
		document.forms.calc.result.value = RESULT_PASS;
	else
		document.forms.calc.result.value = RESULT_FAIL;
} // function calculate()
