var Total_Question = 3		// Remember to change this value

var msg = ""

// These are the solutions
  var Solution = new Array(Total_Question)
  Solution[0] = "ANSWER: b - <B>Fuel cells</b> convert the fuel bound energy directly into electricity, which substantially reduces pollution"
  Solution[1] = "ANSWER: d - <B>All the above</b> - hot water, automobiles, wind, all produces energy."
  Solution[2] = "ANSWER: b - The <B>United States</B> consumes the most energy per capita"
// end of solutions

function GetSelectedButton(ButtonGroup)
{
  for (var x=0; x < ButtonGroup.length; x++)
    if (ButtonGroup[x].checked) return x
  return 0
} 

function ReportScore(correct)
{ 
  var SecWin = 
      window.open("","","scrollbars,width=300,height=300")
  var MustHave1 = "<HTML><HEAD><TITLE>Your Score</TITLE></HEAD><BODY>"
  var Percent = "<H2>Score : "+Math.round(correct/Total_Question*100)
		 + "%</H2><HR>Answers to the questions you missed: <P>"
		 
  msg = MustHave1 +Percent + msg  + "</BODY></HTML>"
  
  SecWin.document.write(msg)
  msg = ""  // Clear message
}

function Grade()
{
  var correct = 0
  var wrong = 0
  for (number=0; number < Total_Question; number++)
    {
      var form = document.forms[number]      // Question #
      var i = GetSelectedButton(form.q1)
      if (form.q1[i].value == "1")
	 { correct++ } 
	else 
	 { wrong++
	   msg += "<H4>Question "+(number+1)+".</H4>"
		  +Solution[number]+"<BR>"
	 }
    }
    ReportScore(correct)

}