var NP = 20;
var probdat = new Object;
var adat = new Object;
var bdat = new Object;
var cdat = new Object;
var ddat = new Object;
var hints = new Object;
var tested = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
var pm = new Array(1,2,3,4);
var mp = new Array(1,2,3,4);
var ans = new Array(11,10,10,7,12,10,5,5,3,10,4,5,4,6,0,6,13,12,1,9);
var hn = new Array(0,0,1,2,3,0,4,5,6,2,-7,8,9,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,1,25,26,27,2,28,29,-30,31,32,0,33,34,35,36,2,37,38,13,14,19,39,14,40,41,31,13,-42,-43,13,13,44,45,46,47,39,48,49,41,18,18,50,51,52,-53,54,55,2,56,57,39);

hints[0] = "See The Extreme Value Theorem (&nbsp;p. 275&nbsp;)";
hints[1] = "Try <I>f</I>(<I>x</I>)=-<I>x</I>";
hints[2] = "See The Intermediate Value Theorem (&nbsp;p. 127&nbsp;)";
hints[3] = "Try <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"296\" HEIGHT=\"54\" SRC=\"h/img1.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[4] = "Try <I>f</I>(<I>x</I>)=<I>x</I>+4";
hints[5] = "The product of two continuous functions is a continuous function (&nbsp;see Theorem 4, p.123&nbsp;)";
hints[6] = "Try <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"284\" HEIGHT=\"54\" SRC=\"h/img2.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[7] = "Take <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"284\" HEIGHT=\"54\" SRC=\"h/img2.gif\"></DIV><BR CLEAR=\"ALL\"><P></P>Then <I>g</I>(5.5) is undefined";
hints[8] = "The sum of two continuous functions is a continuous function (&nbsp;see Theorem 4, p. 123&nbsp;)";
hints[9] = "It's obvious";
hints[10] = "The sum of two increasing functions is an increasing function";
hints[11] = "The quotient of two continuous functions is a continuous function on its domain (&nbsp;see Theorem 4, p.123;<IMG WIDTH=\"82\" HEIGHT=\"35\" ALIGN=\"MIDDLE\" SRC=\"h/img3.gif\"> on [4,10]&nbsp;)";
hints[12] = "Take <I>f</I>(<I>x</I>)=<I>x</I>-5";
hints[13] = "Take <I>f</I>(<I>x</I>)=<I>x</I>";
hints[14] = "Try <I>f</I>(<I>x</I>)=<I>x</I><SUP>2</SUP>";
hints[15] = "(0,10] in not closed! Try <IMG WIDTH=\"80\" HEIGHT=\"59\" ALIGN=\"MIDDLE\" SRC=\"h/img4.gif\">";
hints[16] = "(0,10] is not closed! Try <IMG WIDTH=\"96\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img5.gif\">";
hints[17] = "Take <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"206\" HEIGHT=\"54\" SRC=\"h/img6.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[18] = "Example: <I>f</I>(<I>x</I>)=1 for all <I>x</I>";
hints[19] = "Take <I>f</I>(<I>x</I>)=<I>e</I><SUP><I>x</I></SUP>";
hints[20] = "Since <IMG WIDTH=\"123\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"h/img7.gif\"> we have <IMG WIDTH=\"133\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img8.gif\"> and <I>f</I>(0)=0. See the Squeeze Theorem (&nbsp;p. 117&nbsp;)";
hints[21] = "Take <IMG WIDTH=\"139\" HEIGHT=\"59\" ALIGN=\"MIDDLE\" SRC=\"h/img9.gif\">. Then <IMG WIDTH=\"183\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"h/img10.gif\"> - not continuous at <I>x</I>=0";
hints[22] = "<IMG WIDTH=\"117\" HEIGHT=\"38\" ALIGN=\"MIDDLE\" SRC=\"h/img11.gif\">";
hints[23] = "<I>f</I>(0)=0 is a minimum";
hints[24] = "-<I>f</I> is increasing and <I>g</I> is a sum of two increasing functions"
hints[25] = "The quotient of two continuous functions is a continuous function on its domain (&nbsp;see Theorem 4, p.123&nbsp;)";
hints[26] = "Take <I>f</I>(<I>x</I>)=2-<I>x</I>";
hints[27] = "Take <I>g</I>(<I>x</I>)=<I>f</I>(<I>x</I>)-<I>x</I> and apply the Intermediate Value Theorem (&nbsp;p. 127&nbsp;) for <I>g</I>";
hints[28] = "Take <I>f</I>(<I>x</I>)=<I>x</I><SUP>2</SUP>-6<I>x</I>+7";
hints[29] = "Take <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"275\" HEIGHT=\"55\" SRC=\"h/img12.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[30] = "<IMG WIDTH=\"59\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img13.gif\"> and <IMG WIDTH=\"74\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img14.gif\"> are undefined";
hints[31] = "See Definition 2 p. 122";
hints[32] = "Take <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"288\" HEIGHT=\"55\" SRC=\"h/img15.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[33] = "Take <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"237\" HEIGHT=\"68\" SRC=\"h/img16.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[34] = "Take <I>g</I>(<I>x</I>)=1 for all <IMG WIDTH=\"91\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img17.gif\"> then <I>f</I>(<I>x</I>)=<I>x</I>";
hints[35] = "<I>f</I>(0)=0";
hints[36] = "Take <I>g</I>(<I>x</I>)=1 for all <IMG WIDTH=\"91\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img17.gif\"> then <I>f</I>(<I>x</I>)=<I>x</I>";
hints[37] = "Take <IMG WIDTH=\"114\" HEIGHT=\"59\" ALIGN=\"MIDDLE\" SRC=\"h/img18.gif\">";
hints[38] = "<IMG WIDTH=\"295\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img19.gif\"> so by the Squeeze Theorem (&nbsp;p. 117&nbsp;), <IMG WIDTH=\"201\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img20.gif\">";
hints[39] = "See Theorem 9, p. 126";
hints[40] = "Take <I>f</I>(<I>x</I>)=<I>x</I>+1";
hints[41] = "See Theorem 4, p.123";
hints[42] = "<IMG WIDTH=\"198\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img21.gif\"> - closed interval";
hints[43] = "<IMG WIDTH=\"153\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img22.gif\">";
hints[44] = "Let <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"212\" HEIGHT=\"68\" SRC=\"h/img23.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[45] = "<I>g</I> is a constant";
hints[46] = "<IMG WIDTH=\"202\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img24.gif\">";
hints[47] = "Take <BR><P></P><DIV ALIGN=\"CENTER\"><IMG WIDTH=\"245\" HEIGHT=\"68\" SRC=\"h/img25.gif\"></DIV><BR CLEAR=\"ALL\">";
hints[48] = "Take <I>f</I>(<I>x</I>)=<I>x</I>-1";
hints[49] = "<I>g</I>(1)=0";
hints[50] = "Otherwise we would have <I>f</I>(-1)&lt;<I>f</I>(1)";
hints[51] = "<IMG WIDTH=\"28\" HEIGHT=\"16\" ALIGN=\"BOTTOM\" SRC=\"h/img26.gif\"> and <I>f</I> are continuous at <IMG WIDTH=\"35\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img27.gif\">";
hints[52] = "Use the Squeeze Theorem";
hints[53] = "<I>h</I>(<I>x</I>) is undefined for any <I>x</I>";
hints[54] = "Take <I>f</I>(<I>x</I>)=1-<I>e</I><SUP>-<I>x</I><SUP>2</SUP></SUP>"
hints[55] = "Take <IMG WIDTH=\"103\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"h/img28.gif\">";
hints[56] = "Take <I>f</I>(<I>x</I>)=2<I>x</I>-6";
hints[57] = "Try <I>f</I>(<I>x</I>)=-2<I>x</I>+6";



probdat[1] = "<I>f</I> is continuous on [2,7]";
adat[1] = "<I>f</I> has a maximum on [2,7]"
bdat[1] = "<I>f</I> has a minimum on [2,7]"
cdat[1] = "<I>f</I>(2)&lt;<I>f</I>(7)"
ddat[1] = "if <I>c</I> is between <I>f</I>(2) and <I>f</I>(7), then there exists <I>d</I> in [2,7] such that <I>f</I>(<I>d</I>)=<I>c</I>";

probdat[2] = "<I>f</I> is continuous on [-3,7]"
adat[2] = "<IMG WIDTH=\"133\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img1.gif\">"
bdat[2] = "<I>f</I> has a minimum on [-3,7]"
cdat[2] = "<I>f</I> has a root on [-3,7]"
ddat[2] = "<IMG WIDTH=\"153\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img2.gif\">"

probdat[3] = "<I>f</I> is continuous on [2,9], <I>f</I>(2)=3, <I>f</I>(9)=-7";
adat[3] = "<I>f</I> is decreasing on [2,9]";
bdat[3] = "<I>f</I> has a root in [2,9]";
cdat[3] = "the function <IMG WIDTH=\"105\" HEIGHT=\"59\" ALIGN=\"MIDDLE\" SRC=\"img3.gif\"> is continuous on [2,9]";
ddat[3] = "<IMG WIDTH=\"229\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img4.gif\">";

probdat[4] = "<I>f</I> is continuous and increasing on [4,10]";
adat[4] = "<I>f</I>(4) is the minimum of <I>f</I>";
bdat[4] = "<I>g</I>(<I>x</I>)=<I>x</I>+<I>f</I>(<I>x</I>) is increasing on [4,10]";
cdat[4] = "<IMG WIDTH=\"113\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img5.gif\"> is continuous on [4,10]";
ddat[4] = "<I>f</I> has no root on [4,10]";

probdat[5] = "<I>f</I> is continuous on (0,10]";
adat[5] = "<IMG WIDTH=\"82\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img6.gif\"> does not exist";
bdat[5] = "<IMG WIDTH=\"105\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img7.gif\"> is not continuous at <I>x</I>=0";
cdat[5] = "<I>f</I> need not have a maximum";
ddat[5] = "<I>f</I> need not have a minimum";

probdat[6] = "<I>f</I> is continuous on <IMG WIDTH=\"144\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img8.gif\">";
adat[6] = "<IMG WIDTH=\"185\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img9.gif\">";
bdat[6] = "<I>f</I> need not have a root on <IMG WIDTH=\"144\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img8.gif\">"
cdat[6] = "<I>f</I> must have a minimum";
ddat[6] = "if <I>f</I>(2)=2 and <I>f</I>(5)=8 then there exists <I>d</I> such that <I>f</I>(<I>d</I>)=4";

probdat[7] = "<I>f</I> is continuous and <IMG WIDTH=\"120\" HEIGHT=\"38\" ALIGN=\"MIDDLE\" SRC=\"img10.gif\"> for every <I>x</I>";
adat[7] = "<IMG WIDTH=\"105\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img11.gif\">, <I>g</I>(0)=0, is continuous at <I>x</I>=0";
bdat[7] = "<IMG WIDTH=\"106\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img12.gif\">, <I>h</I>(0)=0, is continuous at <I>x</I>=0";
cdat[7] = "<I>f</I>(<I>x</I>) has a root";
ddat[7] = "<I>f</I> need not have a minimum";

probdat[8] = "<I>f</I> is continuous and decreasing on [-1,3]";
adat[8] = "<I>g</I>(<I>x</I>)=<I>x</I>-<I>f</I>(<I>x</I>) is increasing on [-1,3]";
bdat[8] = "<IMG WIDTH=\"110\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img13.gif\"> for all <IMG WIDTH=\"91\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img14.gif\">";
cdat[8] = "<IMG WIDTH=\"140\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img15.gif\">";
ddat[8] = "<I>f</I> has a root on [-1,3]";

probdat[9] = "<I>f</I> is continuous on [1,3] and <I>f</I>(1)=2, <I>f</I>(3)=-2";
adat[9] = "The equation <I>x</I>=<I>f</I>(<I>x</I>) has at least one root";
bdat[9] = "<I>g</I>(<I>x</I>)=<I>xf</I>(<I>x</I>) has a root on [1,3]";
cdat[9] = "<IMG WIDTH=\"75\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img16.gif\">";
ddat[9] = "<IMG WIDTH=\"126\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img17.gif\"> for all <IMG WIDTH=\"76\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img18.gif\">"

probdat[10] = "<I>f</I> is continuous on <IMG WIDTH=\"76\" HEIGHT=\"52\" ALIGN=\"MIDDLE\" SRC=\"img19.gif\">";
adat[10] = "<IMG WIDTH=\"108\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img20.gif\"> is continuous on <IMG WIDTH=\"98\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img21.gif\">";
bdat[10] = "<IMG WIDTH=\"164\" HEIGHT=\"52\" ALIGN=\"MIDDLE\" SRC=\"img22.gif\">";
cdat[10] = "<IMG WIDTH=\"164\" HEIGHT=\"52\" ALIGN=\"MIDDLE\" SRC=\"img23.gif\">";
ddat[10] = "<I>f</I> has a maximum on <IMG WIDTH=\"98\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img21.gif\">";

probdat[11] = "<I>g</I> is defined on [-1,1], <I>f</I>(<I>x</I>)=<I>xg</I>(<I>x</I>) is continuous on [-1,1]";
adat[11] = "<I>g</I> is continuous on [-1,1]";
bdat[11] = "<I>g</I> has a root on [-1,1]";
cdat[11] = "<I>f</I> has a root on [-1,1]";
ddat[11] = "<I>f</I> has a maximum on [-1,0)";

probdat[12] = "<I>f</I> is continuous on [-2,8)";
adat[12] = "There exists <IMG WIDTH=\"93\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img24.gif\"> such that <IMG WIDTH=\"197\" HEIGHT=\"39\" ALIGN=\"MIDDLE\" SRC=\"img25.gif\">";
bdat[12] = "<I>f</I> has a maximum on [-2,8)";
cdat[12] = "<IMG WIDTH=\"167\" HEIGHT=\"38\" ALIGN=\"MIDDLE\" SRC=\"img26.gif\"> exists";
ddat[12] = "<I>f</I> is not increasing";

probdat[13] = "<I>f</I> is continuous on <IMG WIDTH=\"81\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img27.gif\">";
adat[13] = "<I>f</I> does not have a minimum";
bdat[13] = "<I>f</I> has a root";
cdat[13] = "<IMG WIDTH=\"127\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img28.gif\"> is continuous";
ddat[13] = "<I>f</I>(-1)&lt;0&lt;<I>f</I>(1)";

probdat[14] = "<I>f</I> is continuous at <I>x</I>=0";
adat[14] = "<IMG WIDTH=\"107\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img29.gif\">";
bdat[14] = "<I>g</I>(<I>x</I>)=<I>x</I><SUP>2</SUP><I>f</I>(<I>x</I>) is continuous at <I>x</I>=0";
cdat[14] = "<IMG WIDTH=\"187\" HEIGHT=\"38\" ALIGN=\"MIDDLE\" SRC=\"img30.gif\">";
ddat[14] = "<I>f</I> is not continuous at <I>x</I>=1";

probdat[15] = "<I>f</I> is continuous on <IMG WIDTH=\"120\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img31.gif\">";
adat[15] = "<I>f</I> need not have a maximum on <IMG WIDTH=\"120\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img31.gif\">";
bdat[15] = "<I>f</I> is not continuous at <I>x</I>=0";
cdat[15] = "<I>f</I> does not have a root on <IMG WIDTH=\"120\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img31.gif\">";
ddat[15] = "<IMG WIDTH=\"185\" HEIGHT=\"38\" ALIGN=\"MIDDLE\" SRC=\"img32.gif\">";

probdat[16] = "<I>f</I> is continuous on <IMG WIDTH=\"120\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img33.gif\"> and <I>f</I>(0) is defined";
adat[16] = "<I>f</I> is continuous on [-1,1]";
bdat[16] = "<I>g</I>(<I>x</I>)=<I>f</I>(0) is continuous on [-1,1]";
cdat[16] = "<I>f</I> is continuous on (-1,0)";
ddat[16] = "There exists <I>d</I>, -1&lt;<I>d</I>&lt;1, such that <I>f</I>(<I>d</I>)=1";

probdat[17] = "<I>f</I> is continuous on [1,2]";
adat[17] = "<I>e</I><SUP><I>f</I>(<I>x</I>)</SUP> is continuous on [1,2]";
bdat[17] = "<IMG WIDTH=\"71\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img34.gif\"> is continuous on [1,2]";
cdat[17] = "<I>g</I>(<I>x</I>)=<I>xf</I>(<I>x</I>)-<I>f</I>(<I>x</I>) has a root on [1,2]";
ddat[17] = "<IMG WIDTH=\"45\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img35.gif\"> has a maximum on [1,2]";

probdat[18] = "<I>f</I> is continuous on [-1,1], <I>f</I>(-1)=<I>f</I>(1)";
adat[18] = "There exists <IMG WIDTH=\"88\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img36.gif\"> such that <IMG WIDTH=\"114\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img37.gif\">";
bdat[18] = "<I>f</I> has a root on [-1,1]";
cdat[18] = "<I>f</I> cannot be strictly increasing";
ddat[18] = "<IMG WIDTH=\"212\" HEIGHT=\"62\" ALIGN=\"MIDDLE\" SRC=\"img38.gif\">";

probdat[19] = "<IMG WIDTH=\"126\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img39.gif\"> for all <IMG WIDTH=\"52\" HEIGHT=\"34\" ALIGN=\"MIDDLE\" SRC=\"img40.gif\">";
adat[19] = "<I>g</I>(<I>x</I>)=<I>xf</I>(<I>x</I>) is continuous at <I>x</I>=0";
bdat[19] = "<IMG WIDTH=\"176\" HEIGHT=\"44\" ALIGN=\"MIDDLE\" SRC=\"img41.gif\"> is continuous";
cdat[19] = "<I>f</I> has a maximum";
ddat[19] = "<IMG WIDTH=\"79\" HEIGHT=\"37\" ALIGN=\"MIDDLE\" SRC=\"img42.gif\"> exists";

probdat[20] = "<I>f</I> is continuous on [2,4], <I>f</I>(2)=-<I>f</I>(4)";
adat[20] = "<I>f</I> has a root on [2,4]";
bdat[20] = "<I>f</I> cannot be increasing";
cdat[20] = "<I>f</I>(2) is negative";
ddat[20] = "<I>f</I>(2<I>x</I>) in continuous on [1,2]";

var existWin2 = 0;
var num = 1;
var cp = 0;
var good = 0;

function DisplayProblem(problem)
{
  if ( existWin2==0 )
  {
    win2 = window.open("","Problem","location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=550,height=500");
  }
  win2.focus();
  if ( problem==0 )
  {
    cp++;
    with(Math)
    {
      num=floor(NP*random())+1;
      for ( i=0; i<5; i++ )
      {
        m1 = floor(4*random());
        m2 = floor(4*random());
        temp = pm[m1]; pm[m1] = pm[m2]; pm[m2] = temp;
      }
      for ( i=0; i<4; i++ )
      {
        mp[pm[i]-1]=i+1;
      }
    }
    if ( tested[num-1] )
    {
      for ( i=0; i<NP; i++ )
      {
        num = num+1;
        if ( num>NP ) { num=1; } 
        if ( !tested[num-1] ) { break; }
      }
      if ( i==NP )
      {
        DisplayFinalPage();
        return;
      }
    }
  }
  else
  {
    num = problem;
  }    
//  tested[num-1] = 1;
  win2.document.open();
  win2.document.writeln("<body bgcolor=FFFFCC>");
  win2.document.write("<P><B>Problem "+cp+".</B> ");
  win2.document.write(probdat[num]);
  win2.document.writeln("<P>Please select all statements that are <B>always</B> true.<P>");
  win2.document.writeln("<form name=\"testform\"><center><table><tr><td>");
  win2.document.write("<P>");
  win2.document.write("<input type=checkbox  name=\"test\" value=\"1\"> A. ");
  DisplayChoice(pm[0],num,0);
  win2.document.write("<input type=checkbox  name=\"test\" value=\"2\"> B. ");
  DisplayChoice(pm[1],num,0);
  win2.document.write("<input type=checkbox  name=\"test\" value=\"3\"> C. ");
  DisplayChoice(pm[2],num,0);
  win2.document.write("<input type=checkbox  name=\"test\" value=\"4\"> D. ");
  DisplayChoice(pm[3],num,0);
  win2.document.writeln("</td></tr></table><p>");
  win2.document.writeln("<input type=button name=\"but1\" value=\"Check Answer.\" onClick=\"opener.DisplaySolution(this.form)\"></center>");
  win2.document.close();
  existsWin2 = 1;
}

function DisplayChoice(i,num,chk)
{
  if ( i==1 )
  {
     win2.document.write(adat[num]);
  }
  else if ( i==2 )
  { 
     win2.document.write(bdat[num]);
  }
  else if ( i==3 )
  {
     win2.document.write(cdat[num]);
  }
  else
  {
     win2.document.write(ddat[num]);
  }   
  if ( chk==1 )
  {
     win2.document.write("<img src=\"checkmark.gif\" align=\"middle\">");
     good++;
  }
  else if ( chk==2 )
  {
     win2.document.write("<img src=\"wrong.gif\" align=\"middle\">");
  }
  win2.document.writeln("<BR><BR>");
}

function bit(x,k)
{
  return ( (x>>k) & 1 );
}

function DisplayHint(i1,n)
{
  var hind = hn[(n-1)*4+i1-1];
  win2.document.writeln("<FONT COLOR=\"RED\">");
  if ( bit(ans[n-1],i1-1)==1 )
  {
    win2.document.writeln("THIS IS TRUE!&nbsp;&nbsp; ");
  }
  else if ( hind>=0 )
  {
    win2.document.writeln("THIS IS NOT ALWAYS TRUE!&nbsp;&nbsp; ");
  } 
  else
  {
    win2.document.writeln("THIS IS NEVER TRUE!&nbsp;&nbsp; ");
    hind = -hind;
  }
  win2.document.writeln("</FONT>");
  win2.document.write(hints[hind]);
  win2.document.writeln(".<BR><BR>");
}

function DisplaySolution(form)
{
  if ( tested[num-1]!=0 )
  {
    DisplayProblem(0);
    return;
  } 
  tested[num-1] = 1;
  var num1=0;
  for ( i=3; i>=0; i-- )
  {
    num1 = num1*2;
    if ( form.test[mp[i]-1].checked ) { num1 = num1+1; }
  } 
  win2.document.open();
  win2.document.writeln("<body bgcolor=FFFFCC>");
  if ( num1==ans[num-1] )
  {
     win2.document.writeln("<P><H2> YOU ARE RIGHT!!!</H2>");
     win2.document.write("<P><B>Problem "+cp+".</B> ");
     win2.document.write(probdat[num]);
     win2.document.writeln("<P>Your answer:<P>");
     win2.document.writeln("<form name=\"ansform\"><center><table><tr><td>");
     win2.document.write("<P>");
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"1\"");
     if ( bit(num1,pm[0]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> A. ");
     DisplayChoice(pm[0],num,1);
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"2\"");
     if ( bit(num1,pm[1]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> B. ");      
     DisplayChoice(pm[1],num,1);
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"3\"");
     if ( bit(num1,pm[2]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> C. ");
     DisplayChoice(pm[2],num,1);
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"4\"");
     if ( bit(num1,pm[3]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> D. ");  
     DisplayChoice(pm[3],num,1);
     win2.document.writeln("<hr width=\"60%\"></td></tr></table></center></form><p>");
     win2.document.write("<div align=right>:");
     win2.document.write("<a href=\"javascript:opener.DisplayProblem(0)\">");
     win2.document.write("Click here to proceed.</a>");
     win2.document.writeln("<div align=left></FONT>");
  }
  else
  {
     win2.document.writeln("<P><H2> HERE IS WHAT YOU'VE GOT WRONG:</H2>");
     win2.document.write("<P><B>Problem "+cp+".</B> ");
     win2.document.write(probdat[num]);
     win2.document.writeln("<P>Your answer:<P>");
     win2.document.writeln("<form name=\"ansform\"><center><table><tr><td>");
     win2.document.write("<P>");
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"1\"");
     if ( bit(num1,pm[0]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> A. ");
     if ( bit(num1,pm[0]-1)==bit(ans[num-1],pm[0]-1) )
     {  
        DisplayChoice(pm[0],num,1);
     }
     else
     {
        DisplayChoice(pm[0],num,2);
        DisplayHint(pm[0],num);
     }
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"2\"");
     if ( bit(num1,pm[1]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> B. ");      
     if ( bit(num1,pm[1]-1)==bit(ans[num-1],pm[1]-1) )
     {  
        DisplayChoice(pm[1],num,1);
     }
     else
     {
        DisplayChoice(pm[1],num,2);
        DisplayHint(pm[1],num);
     } 
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"3\"");
     if ( bit(num1,pm[2]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> C. ");
     if ( bit(num1,pm[2]-1)==bit(ans[num-1],pm[2]-1) )
     {  
        DisplayChoice(pm[2],num,1);
     }
     else
     {
        DisplayChoice(pm[2],num,2);
        DisplayHint(pm[2],num);
     }
     win2.document.write("<hr width=\"60%\"><input type=checkbox  name=\"test\" value=\"4\"");
     if ( bit(num1,pm[3]-1)==1 )
     {
        win2.document.write(" checked");
     }  
     win2.document.write("> D. ");  
     if ( bit(num1,pm[3]-1)==bit(ans[num-1],pm[3]-1) )
     {  
        DisplayChoice(pm[3],num,1);
     }
     else
     {
        DisplayChoice(pm[3],num,2);
        DisplayHint(pm[3],num);
     }
     win2.document.writeln("</FONT><hr width=\"60%\"></td></tr></table></center></form><p>");
     win2.document.write("<div align=right>:");
     win2.document.write("<a href=\"javascript:opener.DisplayProblem(0)\">");
     win2.document.write("Click here to proceed.</a>");
     win2.document.writeln("<div align=left></FONT>");  
  }
  win2.document.close();
}

function closeWin() 
{
  onerror=null
  if ( existsWin2==1 ) {win2.close()}
}

function percentage(x,y)
{
  return Math.round(1000.0*(x/y))/10.0;
}

function DisplayFinalPage()
{
  for ( i=0; i<NP; i++ )
    tested[i] = 0;
  cp = 0;
  win2.document.open();
  win2.document.writeln("<body bgcolor=FFFFCC>");
  win2.document.write("<b> You have reached the end of this quiz.");
  win2.document.writeln(" Thank you!</b><p>");
  win2.document.writeln("You answered correctly "+good+" questions out of ");
  win2.document.writeln((NP*4)+" possible which makes about "+percentage(good,NP*4)+"%<p>");
  win2.document.write("<a href=\"javascript:opener.DisplayProblem(0)\">");
  win2.document.write("Click here to run the test again.</a><br><br><p>");
  win2.document.write("<a href=\"javascript:opener.closeWin()\">");
  win2.document.write("Click here to quit.</a>");
  win2.document.close();
}
