function init() {
 Score=0;
 Qnum=0;
 document.myform.score.value=0;
 AnswerArray();
Randomize();
NextQstn();

}

function initForCapsQuizzes() {
 Score=0;
 Qnum=0;
 document.myform.score.value=0;
 AnswerArray();
NextQstnCap();

}

function NextQstn() {
  Qnum++
  Points=3
  if (Qnum>MaxQstns)
     { endGame() }
  else
     { Answer=Answ[Qnum]
        initForm() }
}
function endGame() {
  if (Score==MaxPts)
      gameNarr="Quiz over... Perfect Score!"
  else
      gameNarr="Quiz over"
  document.myform.answerbox.value=gameNarr
  document.myform.question.value=""
  document.myform.qnum.value=""
}
function MakeArray(y) {
  for (var j = 1; j <= y; j++)
  {    this[j] = 0;   }
  return this; 
}


function Randomize() {
// scramble the answer list with ScramNum

//question 1 definitely needs to be scrambled consistently...
   ran1 = getRan("5");
   temp = Answ[ran1]
   Answ[ran1] = Answ[1];
   Answ[1] = temp;

   for (i=1; i<=ScramNum; i++) {
        ran1 = getRan("1");   
        ran2 = getRan("12");
//	alert ("ran1="+ran1+" and ran2 = "+ran2);
//	if (ran1 > MaxQstns) { alert ("woops"); }
        temp = Answ[ran1];
        Answ[ran1] = Answ[ran2];
        Answ[ran2] = temp;
    }
 }

function getRan(str) {
  today = new Date();
  ssecs=  today.getSeconds();
  mmins=  today.getMinutes();
  ttime=today.getTime();
 
// gives a number between 0 and 59
//  z = ((ssecs*10+mmins) % 12) + 1;
  z = ((ssecs*10+mmins) % MaxQstns) + 1;

//  y = (ttime*ssecs % 12)+1;
  y = (ttime*ssecs % MaxQstns)+1;

//% 12 gives number between 0 and 11 ... so add +1 to it

   if (str=="1")
     {
//      alert (y);
      return y;
      }
   else
      {
 //     alert (z);
      return z;
       }
 } 

function initForm() {
  Points=3
  document.myform.question.value=Answer
  document.myform.points.value=Points
  document.myform.qnum.value=Qnum
  document.myform.max.value=MaxPts
  document.myform.answerbox.value=""
}

function chkQstn(Guess) {
   if (Qnum>MaxQstns)
      endGame()
   else
   if (Points==0)
     { document.myform.points.value=""
       document.myform.answerbox.value="No more tries...click next question"  }
   else
   if (Answer==Guess) {
       Score = Score + Points
       document.myform.answerbox.value="That's right ...click next question"
       document.myform.score.value=Score
       Points=0
       document.myform.points.value=""
         }
   else
     { Points--
       if (Points==2) {
         document.myform.answerbox.value="No, that's " + Guess + ", try again"
         document.myform.points.value=Points }
       else
       if (Points==1) {
         document.myform.answerbox.value="No, that's " + Guess + ", ...one try left"
         document.myform.points.value=Points }
       else
        { document.myform.points.value=""
          document.myform.answerbox.value="That's " + Guess + ". No more tries ...click next question" }
      } 
}

function SeeMap(page,ht,wd) {
   mapwin=open(page,"DisplayWindow","toolbar=no,directories=no,scrollbars=yes,menubar=no,height="+ht+",width="+wd+",resize=no");
}

function jumpPage(form) {
         i = form.SelectMenu.selectedIndex;
         if (i == 0) return;
       parent.location.href = url[i+1];

         }
function MakeArray2()
         {
         this.length = MakeArray2.arguments.length
         for (var i = 0; i < this.length; i++)
         this[i+1] = MakeArray2.arguments[i]
         }
         



function doPopUp () {

var popUp=false;
	if (popUp) {
	MyWindow=window.open('support.html','MyWindow','toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=550,left=75,top=75');
	}

}

