  if (document.images)   {     image01= new Image(100,100);     image01.src="/media/images/matching/chimp01.jpg";       image02= new Image(100,100);     image02.src="/media/images/matching/chimp02.jpg";	 image03= new Image(100,100);     image03.src="/media/images/matching/chimp03.jpg";	 image04= new Image(100,100);     image04.src="/media/images/matching/chimp04.jpg"; 	 image05= new Image(100,100);     image05.src="/media/images/matching/chimp05.jpg"; 	 image06= new Image(100,100);     image06.src="/media/images/matching/chimp06.jpg"; 	 image07= new Image(100,100);     image07.src="/media/images/matching/banana.jpg";    }   var gamenotstarted = true;function startgame() { pics = new Array("/media/images/matching/chimp01.jpg","/media/images/matching/chimp02.jpg","/media/images/matching/chimp03.jpg","/media/images/matching/chimp04.jpg","/media/images/matching/chimp05.jpg","/media/images/matching/chimp06.jpg");   picused = new Array(0,0,0,0,0,0,2);   placement = new Array(13);             // this array tracks the hidden images   blankcard = false;   gamenotstarted = false;   for (var img=1; img < 13; img++) {     // for each image in the Image array      index = 6;                          // dummy value for while loop      while (picused[index] == 2) {index = Math.floor(Math.random() * pics.length)}      picused[index]++;      document.images[img].src="/media/images/matching/banana.jpg";   // display the blank image      placement[img] = index;                 // note which image is hidden      }   //  set all initial values   matches = 0;   tries = 0;   firstcard = true;   oldcard = 0;   firstimg = 1;   document.game.numtry.value = "";   document.game.message.value = "";   blankup = new Array(14);            // is blank card showing?   for (var blnk=0; blnk < 14; blnk++) {blankup[blnk] = true}   }   // end function startgamefunction showcard(imgnum) {   document.game.message.value = " ";   if (gamenotstarted) {StartGame()}   if (blankup[imgnum]) {      document.images[imgnum].src = pics[placement[imgnum]];      if (firstcard) {                   // first of two clicks?         if (blankcard) {                // do we blank previous cards?            document.images[tempimg].src = "../media/images/matching/banana.jpg";            document.images[tempfirst].src = "../media/images/matching/banana.jpg";            document.images[imgnum].src = pics[placement[imgnum]];            blankcard = false;            }         oldcard = placement[imgnum];         firstimg = imgnum;         firstcard = false;         tries++;         document.game.numtry.value = tries;         }      else {                             // second of two clicks         if (imgnum == firstimg)         // clicked the same card?            {document.game.message.value = 'Click a different card.'}         else {            if (placement[imgnum] == oldcard) {      // is it a match?               matches++;               if (matches < 6) {                  MsgText = "They match!";                  blankcard = false;                  }               else {                  MsgText = "Great job! You won!";                  gamenotstarted = true;                  }               document.game.message.value = MsgText;               blankup[imgnum] = false;               blankup[firstimg] = false;               }            else {                       // not a match               MsgText = "Sorry, no match.";               document.game.message.value = MsgText;               blankcard = true;               tempimg = imgnum;               tempfirst = firstimg;               }            firstcard = true;            firstimg = 1;            }         }      }   else { window.alert("You must select a blank card.", imgnum) }   }   // end function showcard
