//javascript  for FOSSILFUELS.HTML quiz

var Total_Question = 2		// Remember to change this value

var msg = ""

// These are the solutions
  var Solution = new Array(Total_Question)
  Solution[0] = "ANSWER: a - <strong>Natural Gas</strong>"
  Solution[1] = "ANSWER: a - <strong>True</strong>, dinosaur bones are fossils and can be converted to fuel."
// 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)

}
