function Question(text,answer) {
 this.text = text;
 this.answer = answer;
}

answers = new Object();
answers["A"] = "Charles Karadimos";
answers["B"] = "Don Ballwey";
answers["C"] = "Bob and Grace Ade";
answers["D"] = "Steven Gray";
answers["E"] = "Kevin and Deborah Healy";
answers["F"] = "Marti Freund";
answers["G"] = "Sherry Moser";
answers["H"] = "Corki Weeks";
answers["I"] = "Bob McWilliam";
answers["J"] = "Judith Paul and Tom Durden";
answers["K"] = "David Kalish";
answers["L"] = "Doug Johnson";
answers["M"] = "Sue Ross";
answers.length = 13;

questions = new Object();
questions[0] = null; // skip index [0]
questions[1] = new Question("","E");
questions[2] = new Question("","L");
questions[3] = new Question("","D");
questions[4] = new Question("","A");
questions[5] = new Question("","H");
questions[6] = new Question("","B");
questions[7] = new Question("","F");
questions[8] = new Question("","M");
questions[9] = new Question("","C");
questions[10] = new Question("","J");
questions.length = 10;
qo2=questions.length/2;

quiz_title = "CURRENT KALEIDOSCOPE QUIZ";

maximum_score = 100;
penalty_for_wrong_answer = -100/questions.length;
reveal_correct_answer = false;
messageline="";

// ---------------------------------------------------------------------
function choice() {
 for(n=0;n<answers.length;n++)
  eval("document.matching.answer"+n+".checked = false");
 for(n=1;n<=questions.length;n++) {
  sel = eval("document.matching.choice"+n+".selectedIndex");
  eval("document.matching.answer"+sel+".checked = true");
 }
}
function clearall() {
 document.matching.evaluation.value ="";
 for(n=1;n<=questions.length;n++) {
   sel=eval("document.matching.choice"+n);
   sel.selectedIndex=0; 
 }
 document.resultspic.src="quizzes/clear.gif"
 document.messagepic.src="quizzes/clear.gif"
}

function gradeQuiz() {
 wrong = "";
 correct = questions.length;
 score = maximum_score;
 for(n=1;n<=questions.length;n++) {
  sel = eval("document.matching.choice"+n+".selectedIndex");
  if (alpha.charAt(sel) != questions[n].answer) {
   correct -= 1;
   score += penalty_for_wrong_answer;
   wrong += "#"+n+" wrong! "
    +(reveal_correct_answer?"Correct answer is "+questions[n].answer:"")
    +"\r\n";
  }
 }
 
ncorrect=correct/questions.length

if (correct==questions.length) {
  document.resultspic.src="quizzes/results10.gif";
  document.messagepic.src="quizzes/complete.gif";
} else if (ncorrect<.1) {
  document.resultspic.src="quizzes/clear.gif";
  document.messagepic.src="quizzes/empty.gif";
} else {
  ncorrect=parseInt(10*ncorrect)
  document.resultspic.src="quizzes/results"+ncorrect+".gif";
  document.messagepic.src="quizzes/incomplete.gif";
}

 document.matching.evaluation.value ="You answered " + correct + " of " + questions.length + " correctly.\r\n"+wrong;
}

alpha = " ABCDEFGHIJKLM";

document.write('<center><table border><tr><td>'
+'<font face="Verdana, Arial, Helvetica" size=+0 color="#000000">'
+'<center><h4>' + quiz_title + '</h4>'
+'<b><font color="#008888">'
+'<font color="#aa00aa" size=+0>TOPIC: </font>MATCH THE SCOPE TO THE ARTIST</font></b><br>'
+"</center></td></tr></table></center><p>"
+'<font size=-1><i>Directions: Match the kaleidoscopes on the left with the' 
+'<font color="#0000ff"><b> artists</b></font> on the right. Choose your answer from the '
+'dropdown menus to the left of the questions.  Click the <i>Grade the Quiz</i> button below to see how you did.<br><br></i></font>');

//main table form
document.write('<form name="matching">'
+'<center><table cellpadding=0 cellspacing=0>');

//table of menu/kaleidoscope image/question
document.write('<tr><td rowspan=2 valign="top">');

//menu boxes and images

answers_menu = "";
for(n=0;n<answers.length+1;n++) {
 answers_menu += "<option>"+alpha.charAt(n);
}

document.write('<table>');

for(n=1;n<=qo2;n++) {
 nn=n+qo2;
 document.write('<tr><td align="right" valign="middle" height=30>'
+ '<select name="choice'+ n + '" size=1>'+answers_menu+'</select>&nbsp;&nbsp;</td>');
 document.write('<td valign="middle">'
 +'<font face="Verdana, Arial, Helvetica" size=-1 color="#0000ff">' + n +'. <img src="quizzes/quiz3/' + n + '.jpg"></td>');
 
//spacer column
 document.write('<td valign="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>');

 document.write('<td align="right" valign="middle" height=30>'
+'<select name="choice'+ nn + '" size=1>'+answers_menu+'</select>&nbsp;&nbsp;</td>');
 document.write('<td valign="middle">'
 +'<font face="Verdana, Arial, Helvetica" size=-1 color="#0000ff">' + nn +'. <img src="quizzes/quiz3/' + nn + '.jpg"></td></tr>');
}
document.write('</table></td>');

//spacer column (in main table)
document.write('<td rowspan=2 valign="top" width="30"><br></td>');

document.write('<td align="center" valign="top">');

//document.write('<table cellpadding=2 cellspacing=0>');

//answers
answers_text = '<table cellpadding=5 cellspacing=0><tr><td align="center" colspan=2>'
             + '<font face="Verdana, Arial, Helvetica" size=+0 color="#000000">'
             + '<b>ARTISTS</b></font></td></tr>';

for(n=1;n<answers.length+1;n++) {
 answers_text += '<tr><td align="center" valign="bottom">'
 +'<font face="Verdana, Arial, Helvetica" size=-1 color="#0000ff">'
 +'<b>'+ alpha.charAt(n)+ '. </b></td><td valign="bottom">'
 +'<font face="Verdana, Arial, Helvetica" size=-1 color="#0000ff">'
 +'<b>' + answers[alpha.charAt(n)]+'</b></td></tr>';
}
answers_text += "</table></td></tr>";


document.write(answers_text);

//grading and results
document.write('<tr><td valign="top"><table><tr><td align="center" valign="top"');
document.write('<center><input type=button value="Grade the Quiz" '
+'onClick="gradeQuiz()"><input type=button value="Clear answers" onClick="clearall()">'
+'<br><br><textarea rows=8 cols=30 name="evaluation"></textarea><p>');
document.write('<img src="quizzes/clear.gif" height=169 width=175 name="resultspic">'
+'<br><img src="quizzes/clear.gif" height=60 width=250 name="messagepic"></center></td>'
+'</tr></table>');

//Finish up main table
document.write('</table></center></form>');
document.close()
