var ans = [0, 0, 0, 2, 0, 0,  0, 1, 0, 1, 0, 2, 0]; // answer code: true = 0, false = 1, a = 0, b = 1, c = 2...
var did = false;
var total = 12;

function getScore() {

	if(did)
		return;

	var userAns = new Array();
	var notAns = new Array();
	var doSubmit = false;
	var score = 0;

	for (i = 1; i <= total ; i ++) {
		ansId = 'q'+i;
		var node = document.getElementsByName(ansId);

		for (j = 0; j < node.length; j ++){
			if(node[j].checked)
				userAns[i] = j;
		}


		if(userAns[i] === undefined) {
			notAns.push(i.toString())

			if (!doSubmit)
				var r = confirm("You did not answer all the question, do you want to continue to submit?");

			if (r!=true)
				return;
			else
				doSubmit = true;
		}//*/
	}

	
	for (i = 1; i <= total; i ++) {

		if(userAns[i] == ans[i]) {
			score ++;
			$("#a"+i).addClass("answer_correct");
			$("#incorrect"+i).css("display", "none");
		}
		else {
			$("#a"+i).addClass("answer_incorrect");
			$("#correct"+i).css("display", "none");
		}
	}

	did = true;
	$(".answer").show();
    var perc = Math.round((score/12) * 100);

	$("#quizForm").before("<h3>You score " + score + " out of 12 - " + perc + "%</h3>" );
	$("#submit").remove();

	scroll(0,0);
	//*/
}