
    <!--

      triesCount=0;
       solveCount=0;
       showCount=0;
       firstVal=-1;
       firstCellName='';
       var curr_cell_name='';
       var timerStarted=0;

       var timerID;
       var restoreTimerID;
       var clearTimerID;

       var clearImgTimeout;
       var restoreImgTimeout;
       var tStart  = null;
       var busy;
       var image_width;
       var image_height;
       var image_set;

       clearImgTimeout=1000;
       restoreImgTimeout=1000;
       busy=0;

       function createImageArray(len)
       {
         this.length= len; 
         for (i=0; i<len; i++) 
         {
           this[i] = new Image();  
         }
         return this;
       }

       function createImageArray3(len)
       {
         this.length= len; 
         for (i=0; i<len; i++) 
         {
           this[i] = new Image();  
         }
         return this;
       }

       function Init()
       {
         images = new createImageArray(36);
         image_set = document.getElementById("image_set").value;
         form2.theTime.value = "00:00";

         for (i=0; i<18; i++)
         {
           images[i].src= "images/"+image_set+"/image_"+i+".jpg";
         }

         image_width = document.getElementById("image_width").value;
         image_height = document.getElementById("image_height").value;

         gameStat = document.getElementById("StatusId");
         gameStat.style.color = '#3300aa';
         gameStat.value = "    Clicks on two tiles to find two matching pictures";
       }

       function Init3()
       {
         images = new createImageArray(36);

         for (i=0; i<18; i++)
         {
           images[i].src= "images/image_"+i+".gif";
         }
       }

       function ShowImage( x,y )
       {
         try
         {
           var cellName = "cell_" + x + "_" +y;       
           if (document[cellName].disabled == true )
           {
             return;
           }
           if ( busy == 0 )
           {
             busy = 1;
             
             if ( timerStarted == 0 )
             {
               StartTimer();
               timerStarted=1;
             }
             curr_cell_name = "cell_" + x + "_" +y;       
             imageNum = y*6+x;
             cellId = "cell"+imageNum;
             cell = document.getElementById(cellId);
             document[curr_cell_name].src = images[cell.value].src;

             showCount++;
  
             if ( showCount == 1 )
             {
               firstVal=cell.value;
               firstCellName=curr_cell_name;
               busy = 0;
             }
             else if ( showCount == 2 )
             {
               showCount=0;
               if (firstCellName != curr_cell_name)
               {
                 if ( firstVal == cell.value )
                 {
                   //alert ('Match firstVal='+firstVal+' secondVal='+cell.value);
                   solveCount++;
                   clearTimerID  = setTimeout("ClearImages()", clearImgTimeout);
                 }
                 else
                 {
                   restoreTimerID  = setTimeout("RestoreImages()", restoreImgTimeout);
                   //alert ('No match firstVal='+firstVal+' secondVal='+cell.value);
                 }
               }
               else
               {
                 RestoreImages();
               }
               triesCount++;
             }
           }
         }
         catch(err)
         {
           alert("Error in function ShowImage : "+err.description);
         }
       }

       function ShowImage3( x,y )
       {
         try
         {
           if ( busy == 0 )
           {
             busy = 1;
             curr_cell_name = "cell_" + x + "_" +y;       
             imageNum = y*6+x;
             cellId = "cell"+imageNum;
             cell = document.getElementById(cellId);
             document[curr_cell_name].src = images[cell.value].src;

             showCount++;
  
             if ( showCount == 1 )
             {
               firstVal=cell.value;
               firstCellName=curr_cell_name;
               busy = 0;
             }
             else if ( showCount == 2 )
             {
               showCount=0;
               if (firstCellName != curr_cell_name)
               {
                 if ( firstVal == cell.value )
                 {
                   //alert ('Match firstVal='+firstVal+' secondVal='+cell.value);
                   solveCount++;
                   clearTimerID  = setTimeout("ClearImages()", clearImgTimeout);
                 }
                 else
                 {
                   restoreTimerID  = setTimeout("RestoreImages()", restoreImgTimeout);
                   //alert ('No match firstVal='+firstVal+' secondVal='+cell.value);
                 }
               }
               else
               {
                 RestoreImages();
               }
               triesCount++;
             }
           }
         }
         catch(err)
         {
           alert("Error in function ShowImage : "+err.description);
         }
       }

       function RestoreImages () 
       {
          document[firstCellName].src = document.getElementById("temp").src;
          document[curr_cell_name].src = document.getElementById("temp").src;
          busy = 0;
       }

       function RestoreImages3 () 
       {
          document[firstCellName].src = document.getElementById("temp").src;
          document[curr_cell_name].src = document.getElementById("temp").src;
          firstVal=-1;
          firstCellName='';
          busy = 0;
       }

       function ClearImages () 
       {
          //alert(firstCellName);
          //alert(curr_cell_name);

          document[curr_cell_name].src = document.getElementById("blank").src;
          document[curr_cell_name].width = image_width;
          document[curr_cell_name].height = image_height;
          document[firstCellName].src = document.getElementById("blank").src;
          document[firstCellName].width  = image_width;    
          document[firstCellName].height = image_height;

          document[curr_cell_name].disabled=true;
          document[firstCellName].disabled=true;

          firstVal=-1;
          firstCellName='';

          if ( solveCount >= 18 )
          {
            busy = 1;
            StopTimer();
            gameStat = document.getElementById("StatusId");
            gameStat.style.color = '#aa2222';

            str = "                                         ";
            gameStat.value = str;

            percent = ( solveCount * 100 ) / triesCount;
            result = percent.toFixed(); 
            str = "   You did it in "+triesCount+" tries!   Percent correct: "+result+"%";
            gameStat.value = str;
            document["cell_0_2"].src = document.getElementById("b").src;
            document["cell_0_2"].width  = image_width;    
            document["cell_0_2"].height = image_height;
            document["cell_1_2"].src = document.getElementById("r").src;
            document["cell_1_2"].width  = image_width;    
            document["cell_1_2"].height = image_height;
            document["cell_2_2"].src = document.getElementById("a").src;
            document["cell_2_2"].width  = image_width;    
            document["cell_2_2"].height = image_height;
            document["cell_3_2"].src = document.getElementById("v").src;
            document["cell_3_2"].width  = image_width;    
            document["cell_3_2"].height = image_height;
            document["cell_4_2"].src = document.getElementById("o").src;
            document["cell_4_2"].width  = image_width;    
            document["cell_4_2"].height = image_height;
            document["cell_5_2"].src = document.getElementById("es").src;
            document["cell_5_2"].width  = image_width;    
            document["cell_5_2"].height = image_height;
          }
          else
          {
            busy = 0;
          }
       }

       function ClearImages3 () 
       {
          document[firstCellName].width = 0;
          document[firstCellName].height = 0;
          document[curr_cell_name].width = 0;
          document[curr_cell_name].height = 0;

          firstVal=-1;
          firstCellName='';
          busy = 0;
       }

       function ResetTimer() 
       {
         tStart = null;
         form2.theTime.value = "00:00";
       }

       function StartTimer() 
       {
         tStart   = new Date();
         form2.theTime.value = "00:00";
         timerID  = setTimeout("UpdateTimer()", 1000);
       }

       function StopTimer()
       {
         if(timerID) 
         {
           clearTimeout(timerID);
           timerID  = 0;
         }
         tStart = null;
       }

       function UpdateTimer() 
       {
         if(timerID) 
         {
           clearTimeout(timerID);
         }

         if (!tStart)
         {
           tStart   = new Date();
         }
         var   tDate = new Date();
         var   tDiff = tDate.getTime() - tStart.getTime();

         tDate.setTime(tDiff);

         minutes = tDate.getMinutes();
         seconds = tDate.getSeconds();

	 if (seconds < 10) 
	 { 
           seconds = '0' + seconds; 
         }

	 if (minutes < 10) 
	 { 
           minutes = '0' + minutes; 
         }

         form2.theTime.value = minutes + ":" + seconds;
   
         timerID = setTimeout("UpdateTimer()", 1000);
      }


      //-->