// -- AUTHOR: Filippo Spadaro
// -- PROGRAMMER: Filippo Spadaro
// -- LASTREVIEW: 13 febbraio 2002
// -- SITE URL: http://www.geocities.com/nienteperniente

// -- rmbr: sostituire **test.js nelle importazioni JScript dei file HTML
path = "07test.html";
path_fine = "07test_fine.html";

// -- definizioni array --
var t = new Array();

var txtA = new Array();
var txtB = new Array();
var txtC = new Array();
var txtD = new Array();
var txtE = new Array();

var r = new Array();

var pA = new Array();
var pB = new Array();
var pC = new Array();
var pD = new Array();
var pE = new Array();

// -- NB: l'utente deve riempire solo i campi:
// -- txt*[*], t[*], r[*], p*[*]
// -- * --
txtA[0]="<img src='07_01a.gif' width=80 height=80 align=middle>";
txtB[0]="<img src='07_01b.gif' width=80 height=80 align=middle>";
txtC[0]="<img src='07_01c.gif' width=80 height=80 align=middle>";
txtD[0]="<img src='07_01d.gif' width=80 height=80 align=middle>";
txtE[0]="<img src='07_01e.gif' width=80 height=80 align=middle>";
t[0]="<img src='07_01_domanda.gif' align=left width=80 height=80><BR>Test del quadrato che gira. Trovate tra i quadrati elencati sotto, quello uguale al quadrato a fianco:<BR><BR><BR>";
r[0]=txtB[0];
pA[0]=0;pB[0]=1;pC[0]=0;pD[0]=0;pE[0]=0;

// -- * --
txtA[1]="<img src='07_02a.gif' width=80 height=90 align=middle>";
txtB[1]="<img src='07_02b.gif' width=80 height=90 align=middle>";
txtC[1]="<img src='07_02c.gif' width=80 height=90 align=middle>";
txtD[1]="<img src='07_02d.gif' width=80 height=90 align=middle>";
txtE[1]="<img src='07_02e.gif' width=80 height=90 align=middle>";
t[1]="<img src='07_02_domanda.gif' align=left width=80 height=90><BR>Test del cubo che ruota. Trovate tra i cubi elencati sotto, quello uguale al cubo a fianco:<BR><BR><BR>";
r[1]=txtE[1];
pA[1]=0;pB[1]=0;pC[1]=0;pD[1]=0;pE[1]=1;

// -- * --
txtA[2]="<img src='07_03a.gif' width=80 height=80 align=middle>";
txtB[2]="<img src='07_03b.gif' width=80 height=80 align=middle>";
txtC[2]="<img src='07_03c.gif' width=80 height=80 align=middle>";
txtD[2]="<img src='07_03d.gif' width=80 height=80 align=middle>";
txtE[2]="<img src='07_03e.gif' width=80 height=80 align=middle>";
t[2]= "Test di rotazione a 2 dimensioni.<BR><img src='07_03_domanda.gif' width=550 height=76><BR><BR>";
r[2]=txtD[2];
pA[2]=0;pB[2]=0;pC[2]=0;pD[2]=1;pE[2]=0;

// -- * --
txtA[3]="<img src='07_04a.gif' width=90 height=80 align=middle>";
txtB[3]="<img src='07_04b.gif' width=90 height=80 align=middle>";
txtC[3]="<img src='07_04c.gif' width=90 height=80 align=middle>";
txtD[3]="<img src='07_04d.gif' width=90 height=80 align=middle>";
txtE[3]="<img src='07_04e.gif' width=90 height=80 align=middle>";
t[3]= "Test di rotazione a 3 dimensioni.<BR><img src='07_04_domanda.gif' width=550 height=95><BR><BR>";
r[3]=txtC[3];
pA[3]=0;pB[3]=0;pC[3]=1;pD[3]=0;pE[3]=0;

// -- * --
txtA[4]="<img src='07_05a.gif' width=90 height=80 align=middle>";
txtB[4]="<img src='07_05b.gif' width=90 height=80 align=middle>";
txtC[4]="<img src='07_05c.gif' width=90 height=80 align=middle>";
txtD[4]="<img src='07_05d.gif' width=90 height=80 align=middle>";
txtE[4]="<img src='07_05e.gif' width=90 height=80 align=middle>";
t[4]= "Test di rotazione e riflessione a 2 dimensioni.<BR><img src='07_05_domanda.gif' align=middle width=90 height=80>Trovate il disegno uguale a quello a fianco:<BR><BR>";
r[4]= txtC[4];
pA[4]=0;pB[4]=0;pC[4]=1;pD[4]=0;pE[4]=0;

// -- * --
txtA[5]="30  ";
txtB[5]="26  ";
txtC[5]="10  ";
txtD[5]="12  ";
txtE[5]="6  ";
t[5]= "Contare quanti quadrati ci sono nel quadrato in figura:<BR><img src='07_06_quadrati.gif' align=middle width=150 height=150><BR><BR>";
r[5]= txtA[5];
pA[5]=1;pB[5]=0;pC[5]=0;pD[5]=0;pE[5]=0;

// -- * --
txtA[6]="<img src='07_07a.gif' width=90 height=80 align=middle>";
txtB[6]="<img src='07_07b.gif' width=90 height=80 align=middle>";
txtC[6]="<img src='07_07c.gif' width=90 height=80 align=middle>";
txtD[6]="<img src='07_07d.gif' width=90 height=80 align=middle>";
txtE[6]="<img src='07_07e.gif' width=90 height=80 align=middle>";
t[6]= "La figura nascosta.<BR><img src='07_07_domanda.gif' width=800 height=142><BR>Soltanto una delle figure sotto è nascosta in uno dei rettangoli sopra. Trovare qual è!<BR><BR>";
r[6]= txtD[6];
pA[6]=0;pB[6]=0;pC[6]=0;pD[6]=1;pE[6]=0;

// -- * --
txtA[7]="<img src='07_08a.gif' width=80 height=80 align=middle>";
txtB[7]="<img src='07_08b.gif' width=80 height=80 align=middle>";
txtC[7]="<img src='07_08c.gif' width=80 height=80 align=middle>";
txtD[7]="<img src='07_08d.gif' width=80 height=80 align=middle>";
txtE[7]="<img src='07_08e.gif' width=80 height=80 align=middle>";
t[7]= "<img src='07_08_domanda.gif' align=middle width=80 height=100>Identificare il cubo aperto a fianco tra quelli mostrati sotto:<BR><BR>";
r[7]= txtE[7];
pA[7]=0;pB[7]=0;pC[7]=0;pD[7]=0;pE[7]=1;

// -- * --
txtA[8]="1 e 2  ";
txtB[8]="1 e 3  ";
txtC[8]="1 e 4  ";
txtD[8]="5  ";
txtE[8]="2  ";
t[8]= "<img src='07_09_domanda.gif' align=left width=80 height=90><BR>Completare il quadrato a lato, identificando il pezzo o i pezzi tra quelli sotto che lo completano:<BR><BR><BR>1<img src='07_09a.gif' width=80 height=80 align=middle>  2<img src='07_09b.gif' width=80 height=80 align=middle>  3<img src='07_09c.gif' width=80 height=80 align=middle>  4<img src='07_09d.gif' width=80 height=80 align=middle>  5<img src='07_09e.gif' width=80 height=80 align=middle>";
r[8]= txtC[8];
pA[8]=0;pB[8]=0;pC[8]=1;pD[8]=0;pE[8]=0;

// -- * --
txtA[9]="10  ";
txtB[9]="20 ";
txtC[9]="35  ";
txtD[9]="25  ";
txtE[9]="30  ";
t[9]= "Contate quanti triangoli ci sono in questo pentagono:<BR><img src='07_10_pentagono.gif' align=middle width=150 height=150><BR><BR>";
r[9]= txtC[9];
pA[9]=0;pB[9]=0;pC[9]=1;pD[9]=0;pE[9]=0;


// -- funzioni --
function createTempCookie(name, value) {
  	document.cookie=name + "=" + value + ";";
}


function extractCookieValue(val) {
	if ((endOfCookie = document.cookie.indexOf(";", val)) == -1) {
		endOfCookie = document.cookie.length;
	}
  return unescape(document.cookie.substring(val,endOfCookie));
}


function ReadCookie(cookiename) {
	var numOfCookies = document.cookie.length;
	var nameOfCookie = cookiename + "=";
	var cookieLen = nameOfCookie.length;
	var x = 0;
	while (x <= numOfCookies) {
		var y = (x + cookieLen);
		if (document.cookie.substring(x, y) == nameOfCookie)
			return (extractCookieValue(y));
			x = document.cookie.indexOf(" ", x) + 1;
			if (x == 0)
				break;
  		}
	return (null);
}


function getData(i) {
	separatore = "#"
	var VecchioValore = ReadCookie("ordine");
	var NuovoValore = VecchioValore + separatore + document.forms[0].elements[i].name;
	test = parseInt(NuovoValore.charAt(0));
	if ((test > 0) && (test < 9))
	test = parseInt(NuovoValore.charAt(0)) + 1;
	else if (test == 9)
	test = 0;
	else if (test == 0)
	test = "X";
	createTempCookie("ordine", test + NuovoValore);
	//userCookie = ReadCookie("ordine");
}


function leggiDati() {
	userCookie = ReadCookie("ordine");
	var u = 1;
	var bool = 0;
	var totale = 0;
	var numero = new Array();
     	while (bool == 0) {
		if (userCookie.charAt(u) == "") 
			bool = 1;
		if (userCookie.charAt(u) == "#") {	 
			document.write("&nbsp;");
			u+=1;
		}
		if (userCookie.charAt(u) == "£") {
				u+=1;	
				totale = totale 
				+ parseInt(userCookie.charAt(u))*1000
				+ parseInt(userCookie.charAt(u+1))*100
				+ parseInt(userCookie.charAt(u+2))*10
				+ parseInt(userCookie.charAt(u+3));
		}
		u+=1;
	}
	document.write("<BR><FONT SIZE=4 FACE=\x22 courier new\x22 color=Maroon><B>Punteggio parziale: </B></FONT>" 
			+ "<FONT SIZE=5 FACE=\x22 courier new\x22 color=Navy><B>" 
			+ totale + "</B></FONT>");
}


function NuovoOrdine() {	
	createTempCookie("ordine", "1");
}


