
      
function calcScore() {
  if (document.getElementById) {
	var wrongAnsText = "The question(s) you got wrong were: ";
	var score = 0;
	var i;
      
	for(i=1; i <= numQs; i++) {
     
	  //alert("for q " + i + " out of " + numQs + " corr answer is " + ans[i])
	  if(userAns[i]==ans[i]) { score++; }
	  else { wrongAnsText += i +" "; }
	}

      
	if(score == numQs) { wrongAnsText=""; }

	var n = document.getElementById('userScore');
	var scoreP = document.createElement('P');
	var scoreText;
	//###### THIS PART IS DEPENDENT ON THE QUIZZES ONLY HAVING 5 Qs
	switch(score) {
	case 0:
	  scoreText = document.createTextNode("You got " + score + " out of " + numQs + " correct. You seem to be gasping for facts.");
	  break;
	case 1:
	  scoreText = document.createTextNode("You got " + score + " out of " + numQs + " correct. You need to breathe the fresh air of wisdom.");
	  break;
	case 2:
	  scoreText = document.createTextNode("You got " + score + " out of " + numQs + " correct. You have one lung's worth of knowledge.");
	  break;
	case 3:
	  scoreText = document.createTextNode("You got " + score + " out of " + numQs + " correct. You are tobacco-tuned-in.");
	  break;
	case 4:
	  scoreText = document.createTextNode("You got " + score + " out of " + numQs + " correct. You are of very sound mind about sound bodies.");
	  break;
	case 5:
	  scoreText = document.createTextNode("You got " + score + " out of " + numQs + " correct. You are addicted to the truth.");
	  break;
	}

	scoreP.appendChild(scoreText);
	n.appendChild(scoreP);

	var explanationP = document.createElement('P');
	var explanationText = document.createTextNode(wrongAnsText + ". See the explanations below...");
	explanationP.appendChild(explanationText);
	n.appendChild(explanationP);

	var id = " ";
	for (i=1; i<= numQs; i++) {
	  id = "yourAns" + i + userAns[i] + "";
	  document.getElementById(id).style.display = 'inline';
	}


	document.getElementById('quiz').style.display = 'none';
	document.getElementById('userScore').style.display = 'block';
	document.getElementById('explanations').style.display ='block';

	
	
      }
      }

      
