//Initialize answer arrays.
function initarray(){
this.length=initarray.arguments.length
  for (var i=0;i<this.length;i++){
  this[i+1]=initarray.arguments[i];
  }
}

//find which options were selected.  This avoids the "option value" parameter,
//since the index is equivalent to the value.
function getselectedIndex(){
return document.quizform.q1.selectedIndex
return document.quizform.q2.selectedIndex
return document.quizform.q3.selectedIndex
return document.quizform.q4.selectedIndex
return document.quizform.q5.selectedIndex
return document.quizform.q6.selectedIndex
return document.quizform.q7.selectedIndex
return document.quizform.q8.selectedIndex
return document.quizform.q9.selectedIndex
return document.quizform.q10.selectedIndex
return document.quizform.q11.selectedIndex
return document.quizform.q12.selectedIndex
return document.quizform.q13.selectedIndex
return document.quizform.q14.selectedIndex
}

// Validate test answers. ENTER CORRECT ANSWERS HERE 
// (note that top line is "0" and enter text of correct answers below
function scoretest(quizform){
answers=new initarray(3,2,2,4,2,3,4,4,3,4,3,2,3,3)

a=0
counter=0
getselectedIndex()
userinput=new initarray(document.quizform.q1.selectedIndex,
document.quizform.q2.selectedIndex,
document.quizform.q3.selectedIndex,
document.quizform.q4.selectedIndex,
document.quizform.q5.selectedIndex,
document.quizform.q6.selectedIndex,
document.quizform.q7.selectedIndex,
document.quizform.q8.selectedIndex,
document.quizform.q9.selectedIndex,
document.quizform.q10.selectedIndex,
document.quizform.q11.selectedIndex,
document.quizform.q12.selectedIndex,
document.quizform.q13.selectedIndex,
document.quizform.q14.selectedIndex)
for (var i=1;i<15;i++){
   if (userinput[i]==answers[i])
     counter=counter+1 
   else
       a=1
 }
Winopen(a,counter)
}

// Determine text for 'Score' message box.  Note onBlur to assure window closes
// value of counter = number of correct answers
// if a <> 0 then at least one error
function Winopen(a,counter) {
   msg=window.open("","msg","toolbar=no,directories=no,menubar=no,width=300,height=150") 
   msg.document.write("<head><title>Score</title></head>")
   msg.document.write("<BODY onBlur=window.close() bgcolor='##00FF80' text='black'>")
   msg.document.write("<center>"+(100*counter)/14 + "% </CENTER>")

// all correct
  if(a==0){
   msg.document.write("<center><h3>Well Done! You even qualify to post ANSWERS in the local OTR BBSs! <IMG SRC='../images/lsmiley.gif' 'WIDTH=15' 'HEIGHT=15' ALT='Grin'> <br> - 14/14</h3></center>") 
  }
  else{ 
// 1
    if(counter<2){
     msg.document.write("<center><h3>"+counter+"/14 - Err ... have you ever listened to radio? It is that thing WITHOUT the picture tube!</h3></center>")
     }
// 2 3	 
    if(counter>1&& counter<4){
     msg.document.write("<center><h3>"+counter+"/14 - Methinks the batteries in your radio died a long time ago, or your memory cells are fading fast.  Check www.old-time.com for historical information! </h3></center>")
     }

//4 5
    if(counter>3&& counter<6){
     msg.document.write("<center><h3>"+counter+"/14 - This quiz was really a challenge, wasn't it?  Check www.old-time.com for more historical information!</h3></center>")
     }

//6 7	 
    if(counter>5&& counter<8){
     msg.document.write("<center><h3>"+counter+"/14 - Not exactly an expert, are ya?  I hope you had fun with the quiz, though! </h3></center>")
     }

//8 - 10	 
    if(counter>7&& counter<11){
     msg.document.write("<center><h3>"+counter+"/14 - A mediocre performance.  You need to listen to more OTR! Tune in next time for even more fun and excitement <IMG SRC=lsmiley.gif WIDTH=15 HEIGHT=15 ALT=Grin></h3></center>")
     }

//11 - 12
    if(counter>10&& counter<13){
     msg.document.write("<center><h3>"+counter+"/14 - Not too bad!  A little more experience and you too can be the life of the party!</h3></center>")
     }

//13 

    if(counter>12){
     msg.document.write("<center> <h3>"+counter+"/14 - Pretty Good!  You probably could figure out the magic code without the decoder ring!</h3></center>")
     }
  }  
  msg.document.write("<form>")
  if(a==0){
     msg.document.write("<center><input type=button value='OK' onClick='self.close()'></center>")
   }
   else{ 
     msg.document.write("<center><input type=button value='Back to Quiz...' onClick='self.close()'></center>")   
   }
msg.document.write("</form>")
msg.document.write("</body>")
}

function SeeAnswers(){
answers=window.open("","answers","toolbar=no,directories=no,menubar=no,width=300,height=440") 
   answers.document.write("<head><title>Answers</title></head>")
   answers.document.write("<BODY onBlur=window.close() bgcolor=yellow text=black>")
   answers.document.write("<center><h1>Answers</h1></center>")
   answers.document.write("     1. Capt Midnite's enemy was 'Ivan Shark' as played by Boris Aplon.")
   answers.document.write("<P> 2. Sgt Preston's show was originally called <I>Challenge of the Yukon</I>.")
   answers.document.write("<P> 3. Jack Armstrong's Sponsor was Wheaties,   and his school was Hudson High.")
   answers.document.write("<P> 4. Tom Mix's sponsor was Ralston.  His first sidekick was  'Old Wrangler' (Percy Hemus).  The Sheriff was  'Mike Shaw' (Leo Curley)")
   answers.document.write("<P> 5. Superman's creators were Jerry Siegal and Joe Shuster.  The sponsor was Kellog's PEP")
   answers.document.write("<P> 6. Milton Caniff was the creator of Terry and the Pirates.")
      answers.document.write("<form>")
   answers.document.write("<center><input type=button value='OK' onClick='self.close()'></center>")
   answers.document.write("</form>")
   answers.document.write("</body>")  

}





