var numQues = 21;
var numChoi = 4;

var answers = new Array(4);
answers[0] = "Fast thick growth from cut upward";
answers[1] = "More growth from tips";
answers[2] = "Arborist";
answers[3] = "Same trunk height buried inside trunk";
answers[4] = "Shallow and wide";
answers[5] = "Correct structural defects and remove dead branches";
answers[6] = "Collar cut";
answers[7] = "Lower limbs feed the lower trunk making it strong";
answers[8] = "April and October";
answers[9] = "A sheath of cells just below the bark (cambium)";
answers[10] = "All of the statements are false!";
answers[11] = "The first image";
answers[12] = "cutting a ring around the bark, or leaving something tied tightly around the trunk";
answers[13] = "ALL of the pictures";
answers[14] = "All of the causes result in premature tree death";
answers[15] = "Both A and B";
answers[16] = "All are common visitors";
answers[17] = "4 years - 7 years";
answers[18] = "Any of the situations pictured";
answers[19] = "25 years";
answers[20] = "weed, water, mulch";

function getScore(form) {
  var score = 0;
  var currElt;
  var currSelection;

  for (i=0; i<numQues; i++) {
     currElt = i*numChoi;
    for (j=0; j<numChoi; j++) {
      currSelection = form.elements[currElt + j];
      if (currSelection.checked) {
        if (currSelection.value == answers[i]) {
          score++;
          break;
        }
      }  
    }
  }

  score = Math.round(score/numQues*100);
  form.percentage.value = score + "%";

  var correctAnswers = "";
  for (i=1; i<=numQues; i++) {
    correctAnswers += i + ". " + answers[i-1] + "\r\n";
  }
  form.solutions.value = correctAnswers;

}

