/*
   ***************** F1 Memory ******************
   |					  	|
   |  Autore  : Nunziante Contieri 	  	|
   |  WebSite : http://f1italia.altervista.org/ |
   |  E-Mail  : globemasterx@yahoo.it	 	|
   |  Versione: 2.0 (29-07-2004)	 	|
   |					 	|
   **********************************************

   Per favore non cancellate questa introduzione!
   Lo script può essere utilizzato liberamente finchè questa introduzione rimarrà intatta! Grazie.

   L'Autore non si riterrà responsabile di alcun effetto indesiderato dovuto
   all'uso proprio e/o improprio di questo script. Non sono fornite garanzie
   di alcun genere riguardo l'utilizzo e il funzionamento di questo script.

   ---------------------------------------------------------------------------

   Please do not delete this header!
   This script may be used freely as long as this header is intact! Thank you.

   The Author cannot be held responsible for any unwanted effects due to the    
   usage of this JavaScript or any derivative.  No warrantees for usability    
   for any specific application are given or implied. 

*/

// ATTENZIONE: Non modificare il codice seguente!
// (ATTENTION:  Don't edit below!)
var id;
var Ind;
var Ind2;
var Dir;
var Click;
var Gallerie;
var Start = 0;
var Pezzi = 15;
var Indovinate;
var Indovinata = new Array();
var ns6=document.getElementById&&!document.all;
var Menu1 = '<table\ cellpadding=\"0\"\ cellspacing=\"5\"\ border=\"0\"\ height=\"80\">';
Menu1 += '<tr><td\ class=\"Testo\">Studia\ attentamente\ questa\ foto...</td></tr>';
Menu1 += '<tr><td\ class=\"Testo\">...sei\ pronto\ a\ giocare\ con\ F1\-Memory?</td></tr>';
Menu1 += '<tr><td\ class=\"Testo\">Bene\ allora\ clicca\ qui...\ <a\ class=\"Tasti\" onmouseover=\"window.status =\'\'; return true\" href=\"javascript:Gioco\(\)\;\">GIOCA!</a></td></tr></table>';
var Menu2 = '<table\ cellpadding=\"0\"\ cellspacing=\"5\"\ border=\"0\"\ height=\"80\">';
Menu2 += '<tr><td\ class=\"Testo\">Osserva\ la\ porzione\ di\ foto\ qui\ accanto...</td></tr>';
Menu2 += '<tr><td\ class=\"Testo\">...ricordi\ dove\ era\ posizionata?</td></tr>';
Menu2 += '<tr><td\ class=\"Testo\">Clicca\ in\ uno\ dei\ riquadri\ in\ alto\ e\ lo\ scoprirai...</td></tr></table>';

function Gioco() {
Ind = 0;
Ind2 = 16;
Click = 0;
Indovinate = 0;
for (i=0; i<=14 ; i++) {
	if (ns6) document.getElementById("Img" + i).src= "casella.gif"; 
	else document.all['Img' + i].src = "casella.gif";
	Indovinata[i] = 0;
}
Testo('3');
Testo('2');
DaIndovinare();
Start = 1;
}

function DaIndovinare() {
Ind = Math.floor(Math.random()*Pezzi);
if (Indovinata[Ind] != 1 && Ind != Ind2) {
	if (ns6) document.getElementById("Img").src = Dir + "/Img" + Ind + ".jpg";
	else document.all["Img"].src = Dir + "/Img" + Ind + ".jpg";
	Ind2 = Ind;
}
else {
	if (Indovinate < 14) { DaIndovinare(); }
	else {  
		for (i=0; i<=14 ; i++) { 
			if (Indovinata[i] == 0) {
				if (ns6) document.getElementById("Img" + i).src = Dir + "/Img" + i + ".jpg";
				else document.all['Img' + i].src = Dir + "/Img" + i + ".jpg";
			}
		}
		if (ns6) document.getElementById("Img").src = "casella.gif";
		else document.all["Img"].src = "casella.gif";
		Testo('1');
	}
 }
}

function Indovina(num){ 
var A = ""+num;
var B = ""+Ind2; 
if (Start == 1){
if (Indovinata[num] == 0) {
	Click++;
	Mostra(num,'1');
	if (A == B) { 
		if (ns6) document.getElementById("Img" + num).src = Dir + "/Img" + num + ".jpg";
		else document.all['Img' + num].src = Dir + "/Img" + num + ".jpg";
		Indovinata[num] = 1;
		Indovinate++;
		Testo('3');
		DaIndovinare();
	}
	else { Start=0; id = setInterval("Mostra("+num+",'0')",500); Testo('3');}
}
}
}

function Mostra(num,mod){
if (mod == '1') { 
	if (ns6) document.getElementById("Img" + num).src = Dir + "/Img" + num + ".jpg";
	else document.all['Img' + num].src = Dir + "/Img" + num + ".jpg";
}
else { 	window.clearInterval (id);
	if (ns6) document.getElementById("Img" + num).src = "casella.gif";
	else document.all['Img' + num].src = "casella.gif";
	DaIndovinare(); }
Start=1;
}

function Testo(t) {
if (t == '1') {
	if (ns6) {
		document.getElementById("Menu").innerHTML = Menu1;
		document.getElementById("Punti").innerHTML = Gallerie;
	}
	else {
		document.all["Menu"].innerHTML = Menu1;
		document.all["Punti"].innerHTML = Gallerie;
	}
}
else if (t == '2') { 
	if (ns6) document.getElementById("Menu").innerHTML = Menu2;
	else document.all["Menu"].innerHTML = Menu2;
}
else if (t == '3') {
	if (ns6) document.getElementById("Punti").innerHTML = "Indovinate:\ " + Indovinate + "/15\ \-\ Tentativi:" + Click;
	else document.all["Punti"].innerHTML = "Indovinate:\ " + Indovinate + "/15\ \-\ Tentativi:" + Click;
}
}

function Galleria(scelta){
Dir = scelta;
if (Dir == "FotoA") Gallerie = 'Seleziona Foto:\ 1\ \-\ <a\ onmouseover=\"window.status =\'\'; return true\" class=\"Tasti\" href=\"javascript:Galleria(\'FotoB\')\">2</a>\ \-\ <a\ onmouseover=\"window.status =\'\'; return true\" class=\"Tasti\" href=\"javascript:Galleria(\'FotoC\')\">3</a>';
else if (Dir == "FotoB") Gallerie = 'Seleziona Foto:\ <a\ onmouseover=\"window.status =\'\'; return true\" class=\"Tasti\" href=\"javascript:Galleria(\'FotoA\')\">1</a>\ \-\ 2\ \-\ <a\ onmouseover=\"window.status =\'\'; return true\" class=\"Tasti\" href=\"javascript:Galleria(\'FotoC\')\">3</a>';
else if (Dir == "FotoC") Gallerie = 'Seleziona Foto:\ <a\ onmouseover=\"window.status =\'\'; return true\" class=\"Tasti\" href=\"javascript:Galleria(\'FotoA\')\">1</a>\ \-\ <a\ onmouseover=\"window.status =\'\'; return true\" class=\"Tasti\" href=\"javascript:Galleria(\'FotoB\')\">2</a>\ \-\ 3';
	for (i=0; i<=14 ; i++) {
		if (ns6) document.getElementById("Img" + i).src = Dir + "/Img" + i + ".jpg";
		else document.all['Img' + i].src = Dir + "/Img" + i + ".jpg";
	}
Testo('1');
}

function F1Memory() {
Start=0;
var Gioco = "";
Gioco += "<table cellpadding=\"0\" cellspacing=\"5\" border=\"0\">";
Gioco += "<tr><td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"Titolo\">";
Gioco += "<tr><td class=\"TitoloA\">F1-Memory</td>";
Gioco += "    <td class=\"TitoloB\">, gioco offerto da &nbsp;<a class=\"Link\" href=\"http://f1italia.altervista.org\" target=\"_blank\">&lt;&lt; Formula 1 - Italia &gt;&gt;</a></td>";
Gioco += "    <td class=\"TitoloC\"><a class=\"Link\" href=\"javascript:F1Memory();\" onmouseover=\"window.status=\'Clicca per riavviare il gioco!\'; return true\" title=\"Clicca qui per riavviare il gioco!\">Riavvia<br>Gioco</a></tr>";
Gioco += "</table></td></tr>";
Gioco += "<tr><td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"Titolo\">";
Gioco += "<tr><td><a href=\"javascript:Indovina('0');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img0\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('1');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img1\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('2');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img2\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('3');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img3\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('4');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img4\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td></tr>";
Gioco += "<tr><td><a href=\"javascript:Indovina('5');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img5\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('6');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img6\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('7');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img7\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('8');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img8\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('9');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img9\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td></tr>";
Gioco += "<tr><td><a href=\"javascript:Indovina('10');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img10\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('11');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img11\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('12');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img12\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('13');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img13\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td>";
Gioco += "    <td><a href=\"javascript:Indovina('14');\" onmouseover=\"window.status =\'\'; return true\"><img alt=\"\" id=\"Img14\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></a></td></tr>";
Gioco += "</table></td></tr>";
Gioco += "<tr><td><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"Titolo\">";
Gioco += "<tr><td class=\"Menu\"><div id=\"Menu\" align=\"center\"></div></td>";
Gioco += "    <td rowspan=\"2\" align=\"right\"><img alt=\"\" id=\"Img\" src=\"casella.gif\" border=\"0\" width=\"100\" height=\"100\"></td></tr>";
Gioco += "<tr><td class=\"Punti\"><div class=\"Testo\" id=\"Punti\"></div></td></tr>";
Gioco += "</table></td></tr>";
Gioco += "</table>";
if (ns6) document.getElementById("Gioco").innerHTML = Gioco;
else document.all["Gioco"].innerHTML = Gioco;
Galleria('FotoA');
Testo('1');
}
