              count = 0;
              gagne=0;
              tentativi=0;


              imgLoaded = 0;
              CountAffichImg = new Array;
              PathImg = new Array;
              PassVerif = 0;
              ImgRecord = new Array;
              a1 = new Image;
              a2 = new Image;
              a2.src = 'images/couple_cache.gif';

              function loadImg()
              	{
               	a1.src = "images/mem_1.gif";
               	CountImg();
             	a1.src = "images/mem_2.gif";
               	CountImg();
               	a1.src = "images/mem_3.gif";
                CountImg();
                a1.src = "images/mem_4.gif";
                CountImg();
                a1.src = "images/mem_5.gif";
                CountImg();
                a1.src = "images/mem_6.gif";
                CountImg();
                a1.src = "images/mem_7.gif";
                CountImg();
                a1.src = "images/mem_8.gif";
                CountImg();
                a1.src = "images/mem_9.gif";
                CountImg();
                a1.src = "images/mem_0.gif";
                CountImg();
                a1.src = "images/mem_10.gif";
                CountImg();
                a1.src = "images/mem_11.gif";
                CountImg();
                RandomMem('i11',11);
                RandomMem('i12',12);
                RandomMem('i13',13);
                RandomMem('i14',14);
                RandomMem('i15',15);
                RandomMem('i16',16);
                RandomMem('i21',21);
                RandomMem('i22',22);
                RandomMem('i23',23);
                RandomMem('i24',24);
                RandomMem('i25',25);
                RandomMem('i26',26);
                RandomMem('i31',31);
                RandomMem('i32',32);
                RandomMem('i33',33);
                RandomMem('i34',34);
                RandomMem('i35',35);
                RandomMem('i36',36);
                RandomMem('i41',41);
                RandomMem('i42',42);
                RandomMem('i43',43);
                RandomMem('i44',44);
                RandomMem('i45',45);
                RandomMem('i46',46);
                document.messMem.mess.value = "Cerca le coppie";
                }

              function CountImg()
              {
              PathImg[imgLoaded] = a1.src;
              CountAffichImg[imgLoaded] = 0;
              CountAffichImg[imgLoaded+12] = 0;
              imgLoaded++;
              return(true)
              }

              function RandomMem(imgName,ImgNb)
              {
              ImgTemp = Math.round(Math.random() * 11);
              while (CountAffichImg[ImgTemp]>=2)
		{
		ImgTemp = Math.round(Math.random() * 11);
		}
              ImgRecord[ImgNb] = PathImg[ImgTemp];
              CountAffichImg[ImgTemp]++;
              return(true);
              }


              function AddClic(ImgNb,ImgName)
              {
              tentativi++;
              if (PassVerif == 0)
              	{
               	if (ImgName.src != a2.src)
                	{
		        alert('Errore');
            		}
              	else
	        	{
          		ImgName.src = ImgRecord[ImgNb];
            		count++;
              		ImgNamey = ImgName;
                	if (count == 1)
		  	   {
        			ImgNb1=ImgNb;
	         		ImgNamex=ImgNamey;
		         	ImgURL1=ImgRecord[ImgNb];
                            }
		        else
			    {
            		     PassVerif=1;
                             if (ImgRecord[ImgNb] == ImgURL1)
				{
				gagne++;
				if (gagne > 1) s="s";
				else s="";
				document.messMem.mess.value = gagne + ' coppie' + s + ' trovate';
				PassVerif = 0;
				count=0;
					if (gagne==12)
					{
                                          if ((tentativi % 2)== 0)
                                            { 
                                              ten= tentativi/2;
                                            }
                                          else
                                           {
                                             ten=tentativi/2 -0.5;
                                           }
                                          if (ten>=48 )
                                          {
  					    document.messMem.mess.value = "Puoi fare meglio, hai terminato in "+ten+" tentativi"
                                           }
                                          if (ten<48)
                                          {
  					    document.messMem.mess.value = "Benino, hai terminato in "+ten+" tentativi"
                                 	   }
                                          if (ten<32)
                                          {
  					    document.messMem.mess.value = "Bene, hai terminato in "+ten+" tentativi"
                                          }

                                          if (ten<18)
                                          {
  					    document.messMem.mess.value = "Eccellente, hai terminato in "+ten+" tentativi"
                                          }

					}
				}
			     else
				{
				document.messMem.mess.value = "Non è una coppia";
				tempoMem2 = setTimeout("ImgNamey.src='images/couple_cache.gif';ImgNamex.src='images/couple_cache.gif';document.messMem.mess.value = 'Cerca le coppie';PassVerif = 0;", 1200);
				count=0;
				}
			    }
                        }
                }
              }

              ThisPage = location.href;
    