var sol = new Array(0,7,7*17,7,7*17,7*13*17,7*17,7,7*17,7*17,7*17,5,5,5*2,5*2,5,5,5*2,5,5*2,5,6*7,3,3*19,3*19,2,7*23,3*19,2,3*19,2,17,17,17,13*17,13*17,17,17,17,17,17,19,19,19,7*13*17,13*17*19,7*19,13*17*19,19,19,19,2,2,2,2,2,2,3*19,3*19,3*19,3*19,11,11,11,11,23,23,13,13,13,13)
var existsWin2 = 0
var num = 1

function displayProblem(doRandom){

   if (doRandom==0) {
     with(Math){
       num=round(70*random()+1)
       if (num==71) {num=70}
     }
   }
   else {num=doRandom}
   win2=window.open('','Problem','location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=500,height=500')
   win2.focus()
   win2.document.open()
   win2.document.writeln("<body bgcolor=FFFFC0>")
   win2.document.writeln("<b>Problem:</b> Which test would you use to determine whether the series<p><center><img src=\"eq"+num+".gif\"></center><p>is convergent?<p>")
   win2.document.writeln("<form name=\"testform\"><center><table><tr><td><input type=radio name=\"test\" value=\"2\" checked>n<sup>th</sup> Term Test<br><input type=radio name=\"test\" value=\"3\">Geometric Series Test<br>")
   win2.document.writeln("<input type=radio name=\"test\" value=\"5\">Alternating Series Test<br><input type=radio name=\"test\" value=\"7\">Integral Test<br><input type=radio name=\"test\" value=\"11\">p-Series Test<br>")
   win2.document.writeln("<input type=radio name=\"test\" value=\"13\">Comparison Test<br><input type=radio name=\"test\" value=\"17\">Limit Comparison Test<br><input type=radio name=\"test\" value=\"19\">Ratio Test<br>")
   win2.document.writeln("<input type=radio name=\"test\" value=\"23\">Telescoping Series</td></tr></table></center></form>")
   win2.document.writeln("<a href=\"javascript:opener.displaySolution("+num+",document.testform)\">Click here to check answer.</a>")
   win2.document.writeln("<script language=\"JavaScript\" src=\"../../js/copyright.js\"></script>")
   win2.document.close()
   existsWin2=1
}
function displaySolution(num,form) {
   var num1=1
   if (form.test[0].checked) {num1=2}
   else if (form.test[1].checked) {num1=3}
   else if (form.test[2].checked) {num1=5}
   else if (form.test[3].checked) {num1=7}
   else if (form.test[4].checked) {num1=11}
   else if (form.test[5].checked) {num1=13}
   else if (form.test[6].checked) {num1=17}
   else if (form.test[7].checked) {num1=19}
   else num1=23

   win2.document.open()
   win2.document.writeln("<body bgcolor=FFFFC0>")
   win2.document.writeln("<b>Problem:</b> Which test would you use to determine whether the series")
   win2.document.writeln("<p><center><img src=\"eq"+num+".gif\"></center><p>")
   win2.document.writeln("is convergent?<p>")
   win2.document.writeln("<b>Answer:</b><p>You picked the")
   if (num1==2) {win2.document.writeln("<b>n<sup>th</sup> Term Test</b>")}
   if (num1==3) {win2.document.writeln("<b>Geometric Series Test</b>")}
   if (num1==5) {win2.document.writeln("<b>Alternating Series Test</b>")}
   if (num1==7) {win2.document.writeln("<b>Integral Test</b>")}
   if (num1==11) {win2.document.writeln("<b>p-Series Test</b>")}
   if (num1==13) {win2.document.writeln("<b>Comparison Test</b>")}
   if (num1==17) {win2.document.writeln("<b>Limit Comparison Test</b>")}
   if (num1==19) {win2.document.writeln("<b>Ratio Test</b>")}
   if (num1==23) {win2.document.writeln("<b>Telescoping Series</b>")}
   if (sol[num]%num1==0) {
      win2.document.writeln("and you are correct!<p>")
      win2.document.writeln("<div align=right><a href=\"javascript:opener.displayProblem(0)\">Click here for another series.</a>")
   }
   else {
      win2.document.writeln("and you have chosen the incorrect test.<p>")
      win2.document.writeln("<div align=right><a href=\"javascript:opener.displayProblem("+num+")\">Click here to try again.</a>")
   }
   win2.document.writeln("<script language=\"JavaScript\" src=\"../../js/copyright.js\"></script>")
   win2.document.close()
}
function closeWin() {
  onerror=null
  if (existsWin2 ==1) {win2.close()}
}
