
ctr=0;

ttl="Spanish Quiz... test your knowledge!";

/* score: */
psco=100;

/* Deduction for each wrong answer. May
   be the perfect score divided by the
   number of questions.  But if you "weight"
   wrong answers, as we have done in this
   little demo script, it may be higher,
   but must be a whole number.  */
wrans=20;

/* Deduction for each "no answer". Usually
   this will be the simple arithmetical
   perfect score divided by number of
   questions. (A whole number) However,
   again, you are in charge. */
noans=20;

/* Change "nr" below to be equal to the
   number of questions you have on this
   test. (Our demo has 5 questions) */
nr=5;

/* Questions */
ques=new Array();
ques[0]="'It's hot' in Spanish is...";
ques[1]="'Adam's car' in Spanish is...";
ques[2]="'I don't know' in Spanish is...";
ques[3]="'An interesting movie' in Spanish is...";
ques[4]="'How much is it?' in Spanish is...";

/* Correct answers... weak!. */
cor="cbdaa";

/* Answers */
ans=new Array();

ans[0]="Tengo frio";
ans[1]="Hace frio";
ans[2]="Hace calor";
ans[3]="Arriba!";

ans[4]="Adam's carro";
ans[5]="El carro de Adam";
ans[6]="La casa de Adam";
ans[7]="El perro de Adam";

ans[8]="No comprendo";
ans[9]="No creo";
ans[10]="No puedo";
ans[11]="No sé";

ans[12]="Una película interesante";
ans[13]="Una interesante película";
ans[14]="La interesante película";
ans[15]="Una conversación interesante";

ans[16]="¿Cuánto cuesta?";
ans[17]="¿Cómo se dice?";
ans[18]="¿Cómo te llamas?";
ans[19]="¿Quién es tu amiga?";


ns="0123456789"
ls="abcd";
astr="";
ack=new Array();
for (var i=0;i<nr;i++){
 ack[i]=(nr*4)+1;
 }

function lightIt(){
 document.images[flg+ad].src="nr/rbl.gif";
 }
function dimIt(){
 if (ack[Math.floor(flg/4)]!=flg){
  document.images[flg+ad].src="nr/rbd.gif";
  }
 }
function dumpIt(){
 if (ack[Math.floor(flg/4)]==flg){
  document.images[ack[Math.floor(flg/4)]+ad].src="nr/rbd.gif";
  ack[Math.floor(flg/4)]=(nr*4)+1;
  }
 else{
  if (ack[Math.floor(flg/5)]!=flg&&ack[Math.floor(flg/5)]!=(nr*4)+1){
   document.images[ack[Math.floor(flg/4)]+ad].src="nr/rbd.gif";
   }
  document.images[flg+ad].src="nr/rbl.gif";
  ack[Math.floor(flg/4)]=flg;
  }
 }
function ckSco(){
 document.images[ad+(nr*4)].src="nr/cwf2.gif";
 setTimeout('document.images[ad+(nr*4)].src="nr/cwf0.gif"',1000);

 for (var i=0;i<nr;i++){
  u=cor.charAt(i);
  v=ls.indexOf(u)+(i*4);
  document.images[ad+v].src="nr/gbl.gif";
  }
 sco=psco;
 for (var i=0;i<nr;i++){
  if (ack[i]==(nr*4)+1){
   sco-=noans;
   }
  else{
   u=cor.charAt(i);
   v=ls.indexOf(u)+(i*4);
   sco=(v==ack[i]?sco:sco-wrans);
   }
  }
 sco=(sco<0?0:sco); // prevent minus score
 scos=""+sco;
 while (scos.length<3){
  scos="0"+scos;
  }
 document.images[ad+(nr*4)+1].src="nr/yts.gif";
 ctr=ad+(nr*4)+2;
 for (var i=0;i<3;i++){
  nj=ns.indexOf(scos.charAt(i));
  document.images[ctr].src="nr/"+nj+".gif";
  ctr++;
  }
 }
function litbut(){
 document.images[ad+(nr*4)].src="nr/cwf1.gif";
 }
function dimbut(){
 document.images[ad+(nr*4)].src="nr/cwf0.gif";
 }
 ctr=0;

function srand() {
 today=new Date();
 rand=today.getTime();
 picker=""+rand
 picker=picker.charAt((picker.length - 4));
 rec=eval(picker);
 }
/* This little routine is simply used to count the
   number of images you may place on your web page
   prior to the radio buttons.  Just makes the routine
   independent of how you lay your page out. */
function getImgAdd(){
 for (var i=0;i<20;i++){
  if (document.images[i].src.indexOf("rbd.gif")>-1){
   ad=i;
   i=20;
   }
  }
 } 
