// -- AUTHOR: Filippo Spadaro
// -- PROGRAMMER: Filippo Spadaro
// -- LASTREVIEW: 3 agosto 2003
// -- SITE URL: http://utenti.lycos.it/nienteperniente

// -- rmbr: sostituire **test.js nelle importazioni JScript dei file HTML
// ##9
path = "22test.html";
// ##9
path_fine = "22test_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 txtF = new Array();
var txtG = new Array();

var r = new Array();
var esatta = new Array();
commento = new Array();

// -- NB: l'utente deve riempire solo i campi:
// -- txt*[*], t[*], r[*], p*[*]

// -- NB: le prime 2 risposte A - B sono obbligatorie, 
// -- mentre  C - D - E - F - G si possono omettere, basta 
// -- inserire un campo vuoto txt*[*]=""; nella prima delle 
// -- cinque che non si vorrà visualizzare.

// -- * --
txtA[0]="Roberto";
txtB[0]="Alberto";
txtC[0]="Francesco";
txtD[0]="";
txtE[0]="";
txtF[0]="";
txtG[0]="";
t[0]="Alberto ha quatto volte le biglie di Roberto più una; Francesco ha il doppio delle biglie di Roberto più dieci; Roberto ha 10 biglie in meno di Alberto.<BR>Chi ha più biglie?";
esatta[0] = "C";
commento[0] = ". Infatti avranno: Roberto 3 biglie, Alberto 13 biglie, Francesco 16 biglie.";

// -- * --
txtA[1]="1/5 di giro<BR>";
txtB[1]="1 giro e 1/4<BR>";
txtC[1]="5 giri<BR>";
txtD[1]="20 giri";
txtE[1]="";
txtF[1]="";
txtG[1]="";
t[1]="<img src='20_21_22_02_10_domanda.gif' align=left height=200><BR><BR>La ruota dentata X ha 20 denti e fa muovere la ruota Y da 40 denti, che a sua volta fa muovere la ruota Z da 100 denti.<BR>Se Z fa un giro completo, X farà:<BR><BR><BR><BR><BR>";
esatta[1] = "C";
commento[1] = "";

// -- * --
txtA[2]="1&nbsp;&nbsp;";
txtB[2]="3&nbsp;&nbsp;";
txtC[2]="6&nbsp;&nbsp;";
txtD[2]="7&nbsp;&nbsp;";
txtE[2]="9&nbsp;&nbsp;";
txtF[2]="11&nbsp;&nbsp;";
txtG[2]="";
t[2]= "Inserisci il numero mancante.<BR><img src='22_03_domanda.gif' height=300><BR>";
esatta[2] = "D";
commento[2] = ", la somma di ogni riga e di ogni colonna è sempre 16.";

// -- * --
txtA[3]="<img src='22_04_e_domanda.gif' align=middle height=150>";
txtB[3]="<img src='22_04_b_domanda.gif' align=middle height=150><BR>";
txtC[3]="<img src='22_04_c_domanda.gif' align=middle height=150>";
txtD[3]="<img src='22_04_d_domanda.gif' align=middle height=150>";
txtE[3]="";
txtF[3]="";
txtG[3]="";
t[3]= "<img src='22_04_a_domanda.gif' align=left height=100>La figura a fianco è stata deformata. Quale delle figure sotto raffigura una sua possibile deformazione?<BR><BR><BR><BR>";
esatta[3] = "A";
commento[3] = "";

// -- * --
txtA[4]="A&nbsp;&nbsp;";
txtB[4]="B&nbsp;&nbsp;";
txtC[4]="C&nbsp;&nbsp;";
txtD[4]="D&nbsp;&nbsp;";
txtE[4]="E&nbsp;&nbsp;";
txtF[4]="F&nbsp;&nbsp;";
txtG[4]="G&nbsp;&nbsp;";
t[4]= "Inserisci la lettera mancante.<BR><img src='22_05_domanda.gif' width=400><BR>";
esatta[4] = "E";
commento[4] = ", si alternano numeri a lettere le cui posizioni sono date dalla precedente /2 e poi +2.";

// -- * --
txtA[5]="è vero";  
txtB[5]="è falso";  
txtC[5]="dipende dal volume";  
txtD[5]="non sempre è vero";  
txtE[5]="";  
txtF[5]="";  
txtG[5]="";  
t[5]= "Alla pressione di 1 atmosfera l'acqua di solidifica in ghiaccio a 0 °C e bolle a 100 °C.<BR>";
esatta[5] = "A";
commento[5] = "";


// -- * --
txtA[6]="<img src='22_06_e_domanda.gif' width=150 align=middle>";  
txtB[6]="<img src='22_06_b_domanda.gif' width=150 align=middle>";  
txtC[6]="<img src='22_06_c_domanda.gif' width=150 align=middle><BR>";  
txtD[6]="<img src='22_06_d_domanda.gif' width=150 align=middle>";  
txtE[6]="<img src='22_06_a_domanda.gif' width=150 align=middle>";  
txtF[6]="<img src='22_06_f_domanda.gif' width=150 align=middle>";  
txtG[6]="";  
t[6]= "Quale figura indica come appare un orologio quando viene visto in uno specchio?<BR>";
esatta[6] = "B";
commento[6] = "";

// -- * --
txtA[7]="Quelle anteriori";  
txtB[7]="Quelle posteriori";  
txtC[7]="Entrambe";  
txtD[7]="Dipende";  
txtE[7]="";  
txtF[7]="";  
txtG[7]="";  
t[7]= "In questo trattore, quali ruote si consumeranno più in fretta?<BR><BR><img src='22_07_domanda.jpg' width=450><BR>";
esatta[7] = "A";
commento[7] = "";

// -- * --
txtA[8]="<img src='22_09_b_domanda.gif' width=120 align=middle>";
txtB[8]="<img src='22_09_c_domanda.gif' width=115 align=middle>";
txtC[8]="<img src='22_09_d_domanda.gif' width=110 align=middle>";
txtD[8]="<img src='22_09_a_domanda.gif' width=110 align=middle><BR>";
txtE[8]="<img src='22_09_e_domanda.gif' width=110 align=middle>";
txtF[8]="";
txtG[8]="";
t[8]= "<img src='22_09_a_domanda.gif' width=120 align=left><BR><BR>La figura a fianco viene ruotata di 90° a sinistra, quindi viene ribaltata a destra. Qual è la figura che otteniamo?<BR><BR><BR><BR>";
esatta[8] = "E";
commento[8] = "";

// -- * --
txtA[9]="più rapidamente<BR>";
txtB[9]="né più rapidamente né più lentamente<BR>";
txtC[9]="dipende dalle dimensioni dei quarto congegno";
txtD[9]="";
txtE[9]="";
txtF[9]="";
txtG[9]="";
t[9]="<img src='20_21_22_02_10_domanda.gif' align=left height=200><BR>La ruota dentata X ha 20 denti e fa muovere la ruota Y da 40 denti, che a sua volta fa muovere la ruota Z da 100 denti.<BR>Se un quarto congegno è inserito tra X e Y, questo costringerà Z a girare:<BR><BR><BR><BR><BR>";
esatta[9] = "B";
commento[9] = "";


// -- 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");
}

