// -- 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 = "21test.html";
// ##9
path_fine = "21test_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]="20&nbsp;&nbsp;";
txtB[0]="24&nbsp;&nbsp;";
txtC[0]="32&nbsp;&nbsp;";
txtD[0]="34&nbsp;&nbsp;";
txtE[0]="40&nbsp;&nbsp;";
txtF[0]="44&nbsp;&nbsp;";
txtG[0]="";
t[0]="Inserisci il numero che completa la serie:<BR><BR><img src='21_01_domanda.gif' width=400><BR><BR>";
esatta[0] = "F";
commento[0] = ", ogni numero è uguale alla summa dei due numeri precedenti moltiplicata x2";

// -- * --
txtA[1]="stessa direzione della freccia<BR>";
txtB[1]="direzione opposta alla freccia<BR>";
txtC[1]="in parte nella stessa direzione della freccia, in parte in senso antiorario";
txtD[1]="";
txtE[1]="";
txtF[1]="";
txtG[1]="";
t[1]="<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 X gira nel verso indicato dalla freccia, Z si muoverà nella:<BR><BR><BR><BR><BR>";
esatta[1] = "A";
commento[1] = "";

// -- * --
txtA[2]="<img src='21_03_2_domanda.gif' align=middle width=120>";
txtB[2]="<img src='21_03_3_domanda.gif' align=middle width=120>";
txtC[2]="<img src='21_03_4_domanda.gif' align=middle width=120>";
txtD[2]="<img src='21_03_5_domanda.gif' align=middle width=120>";
txtE[2]="";
txtF[2]="";
txtG[2]="";
t[2]= "Quale figura completa la serie?<BR><img src='21_03_1_domanda.gif' width=560><BR>";
esatta[2] = "C";
commento[2] = "";

// -- * --
txtA[3]="<img src='dado_1.gif' width=95>";
txtB[3]="<img src='dado_2.gif' width=95>";
txtC[3]="<img src='dado_3.gif' width=100><BR>";
txtD[3]="<img src='dado_4.gif' width=95>";
txtE[3]="<img src='dado_5.gif' width=100>";
txtF[3]="<img src='dado_6.gif' width=95>";
txtG[3]="";
t[3]= "Quale figura completa la serie?<BR><img src='dado_2.gif' width=95><img src='dado_5.gif' width=100><img src='dado_3.gif' width=100><img src='dado_6.gif' width=95><BR><BR>";
esatta[3] = "D";
commento[3] = ". La serie viene incrementata di 3 alternando con decrementi di 2.";

// -- * --
txtA[4]="10&nbsp;&nbsp;";
txtB[4]="15&nbsp;&nbsp;";
txtC[4]="25&nbsp;&nbsp;";
txtD[4]="5&nbsp;&nbsp;"; 
txtE[4]="17&nbsp;&nbsp;";
txtF[4]="";
txtG[4]="";
t[4]= "Inserisci il numero mancante:<BR><img src='21_04_domanda.gif' width=600><BR>";
esatta[4] = "D";
commento[4] = "";

// -- * --
txtA[5]="Mario";  
txtB[5]="Roberto";  
txtC[5]="Federico";  
txtD[5]="Giorgio";  
txtE[5]="";  
txtF[5]="";  
txtG[5]="";  
t[5]= "Di partenza per una gita Mario ha metà delle focacce di Giorgio, il quale ha il doppio delle focacce di Federico più 2; Roberto ha una focaccia in meno di Marco; Federico ha il doppio delle focacce di Roberto.<BR>Chi ha meno focacce?<BR>";
esatta[5] = "B";
commento[5] = ": Mario ha 1 focaccia e 1/2, Roberto ha 1/2 focaccia, Federico ha 1 focaccia, Giorgio ha 3 focacce.";


// -- * --
txtA[6]="<img src='20_21_07_d_domanda.gif' align=middle height=120>";     
txtB[6]="<img src='20_21_07_f_domanda.gif' align=middle width=110>";      
txtC[6]="<img src='20_21_07_c_domanda.gif' align=middle width=110><BR>";      
txtD[6]="<img src='20_21_07_a_domanda.gif' align=middle height=110>";     
txtE[6]="<img src='20_21_07_e_domanda.gif' align=middle width=110>";  
txtF[6]="<img src='20_21_07_b_domanda.gif' align=middle height=110>";     
txtG[6]="";                                                               
t[6]= "Se <img src='20_21_07_a_domanda.gif' width=110 align=middle> sta a <img src='20_21_07_b_domanda.gif' width=110 align=middle> allora <img src='20_21_07_c_domanda.gif' width=110 align=middle> sta a:<BR><BR>";
esatta[6] = "B";
commento[6] = "";

// -- * --
txtA[7]="A&nbsp;&nbsp;";  
txtB[7]="T&nbsp;&nbsp;";  
txtC[7]="Y&nbsp;&nbsp;";  
txtD[7]="Z&nbsp;&nbsp;";  
txtE[7]="";  
txtF[7]="";  
txtG[7]="";  
t[7]= "Inserisci la lettera mancante:<BR><img src='21_07_domanda.gif' width=500><BR>";
esatta[7] = "C";
commento[7] = ", le lettere stanno occupano le posizioni pari alle potenze successive: 1, 4, 9, 16, 25";

// -- * --
txtA[8]="è vero<BR>";
txtB[8]="a volte è vero<BR>";
txtC[8]="non è vero<BR>";
txtD[8]="è falso<BR>";
txtE[8]="è un'opinione";
txtF[8]="";
txtG[8]="";
t[8]= "Gli animali hanno quattro zampe.<BR>";
esatta[8] = "B";
commento[8] = "";

// -- * --
txtA[9]="1/5 di giro<BR>";
txtB[9]="20 giri<BR>";
txtC[9]="5 giri<BR>";
txtD[9]="1/2 giro";
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 X fa un giro completo, quanti giri farà Y?<BR><BR><BR><BR><BR>";
esatta[9] = "D";
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");
}


