// -- AUTHOR: Filippo Spadaro
// -- PROGRAMMER: Filippo Spadaro
// -- LASTREVIEW: 1 agosto 2003
// -- SITE URL: http://utenti.lycos.it/nienteperniente

// -- rmbr: sostituire **test.js nelle importazioni JScript dei file HTML
// ##9
path = "16test.html";
// ##9
path_fine = "16test_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 4 risposte A - B - C - D sono obbligatorie, 
// -- mentre  E - F - G si possono omettere, basta inserire un 
// -- campo vuoto txt*[*]=""; nella prima delle tre che non si 
// -- vorrà visualizzare.

// -- * --
txtA[0]="19&nbsp;&nbsp;";
txtB[0]="17&nbsp;&nbsp;";
txtC[0]="11&nbsp;&nbsp;";
txtD[0]="13&nbsp;&nbsp;";
txtE[0]="";
txtF[0]="";
txtG[0]="";
t[0]="<img src='16_02_domanda.gif' hspace=10 width=190 align=left><BR>Inserisci il numero mancante nel quadrato a fianco:<BR><BR>";
esatta[0] = "B";
commento[0] = "&Egrave; il 17 perch&eacute; la serie è così composta: 12 (+2), 14 (-1), 13 (+2), 15 (-1), 14 (+2), 16 (-1), 15 (+2), 17";

// -- * --
txtA[1]="(1) - (2)";
txtB[1]="(3) - (4)";
txtC[1]="(1) - (3)";
txtD[1]="(2) - (4)";
txtE[1]="(1) - (4)";
txtF[1]="(3) - (2)";
txtG[1]="";
t[1]="Due di queste parole hanno un significato simile:<BR>(1) <B>spiritoso</B>, (2) <B>superficiale</B>, (3) <B>incapace</B>, (4) <B>scherzoso</B>.<BR><BR>";
esatta[1] = "E";
commento[1] = "";

// -- * --
txtA[2]="12&nbsp;&nbsp;";
txtB[2]="13&nbsp;&nbsp;";
txtC[2]="15&nbsp;&nbsp;";
txtD[2]="17&nbsp;&nbsp;";
txtE[2]="";
txtF[2]="";
txtG[2]="";
t[2]= "Indica con quale numero continua la serie seguente: <BR><img src='16_03_domanda.gif' width=447><BR><BR>";
esatta[2] = "C";
commento[2] = ", infatti è: 9 (+5), 14 (+4), 18 (:3), 6 (+5), 11 (+4), 15";

// -- * --
txtA[3]="4&nbsp;&nbsp;";
txtB[3]="5&nbsp;&nbsp;";
txtC[3]="7&nbsp;&nbsp;";
txtD[3]="9&nbsp;&nbsp;";
txtE[3]="";
txtF[3]="";
txtG[3]="";
t[3]= "<img src='16_04_domanda.gif' hspace=10 width=200 align=left>Quanti rettangoli ci sono in figura?<BR><BR>";
esatta[3] = "C";
commento[3] = "";

// -- * --
txtA[4]="4&nbsp;&nbsp;";
txtB[4]="13&nbsp;&nbsp;";
txtC[4]="14&nbsp;&nbsp;";
txtD[4]="11&nbsp;&nbsp;";
txtE[4]="";
txtF[4]="";
txtG[4]="";
t[4]= "<img src='16_05_domanda.gif' hspace=10 width=260 align=left>Inserisci il numero mancante in figura.<BR><BR>";
esatta[4] = "C";
commento[4] = ", ci sono due serie, una di numeri dispari e l'altra di numeri pari, che aumentano ogni volta entrambe di 2 e alternano la loro posizione, andando su e giù.";

// -- * --
txtA[5]="L";
txtB[5]="M";
txtC[5]="N";
txtD[5]="G";
txtE[5]="";
txtF[5]="";
txtG[5]="";
t[5]= "Inserisci la lettera mancante contrassegnata dal punto interrogativo:<BR><img src='16_06_domanda.gif' width=600><BR><BR>";
esatta[5] = "B";
commento[5] = ": le lettere mancanti sono infatti n - m: ci sono due serie alternate che saltano sempre due lettere.";

// -- * --
txtA[6]="O - E&nbsp;";
txtB[6]="O - F&nbsp;";
txtC[6]="P - F&nbsp;";
txtD[6]="P - E&nbsp;";
txtE[6]="";
txtF[6]="";
txtG[6]="";
t[6]= "<img src='16_07_domanda.gif' align=left width=290>Inserisci le lettere mancanti in figura:<BR>";
esatta[6] = "D";
commento[6] = ". Per le lettere in alto si procede in senso alfabetico, saltando di tre lettere alla volta; per quelle in basso si procede in senso oppposto, saltando di quattro lettere alla volta.";

// -- * --
txtA[7]="<img src='16_08_b_domanda.gif' width=160 align=middle>";
txtB[7]="<img src='16_08_c_domanda.gif' width=160 align=middle>";
txtC[7]="<img src='16_08_d_domanda.gif' width=160 align=middle><BR>";
txtD[7]="<img src='16_08_a_domanda.gif' width=160 align=middle>";
txtE[7]="<img src='16_08_e_domanda.gif' width=160 align=middle>";
txtF[7]="";
txtG[7]="";
t[7]= "<img src='16_08_a_domanda.gif' hspace=10 width=160 align=left>Abbiamo ribaltato la figura a sinistra e poi l'abbiamo fatta ruotare.<BR>Qual è la figura che risulta?<BR><BR><BR><BR><BR><BR>";
esatta[7] = "C";
commento[7] = "";

// -- * --
txtA[8]="6";
txtB[8]="7";
txtC[8]="12";
txtD[8]="14";
txtE[8]="20";
txtF[8]="21";
txtG[8]="28";
t[8]= "<img src='16_09_domanda.gif' align=left hspace=10 width=150>Indica il numero mancante!<BR>";
esatta[8] = "E";
commento[8] = "Le cifre della terza colonna sono ottenute moltiplicando tra di loro le cifre (nelle rispettive righe) della prima e della seconda colonna , quindi dividendo per 2 il prodotto.";

// -- * --
txtA[9]="24"; 
txtB[9]="36"; 
txtC[9]="9";
txtD[9]="20";
txtE[9]="";
txtF[9]="";
txtG[9]="";
t[9]= "<img src='16_10_domanda.gif' align=left hspace=10 width=180>Indica il numero mancante!<BR><BR>";
esatta[9] = "C";
commento[9] = ": 6 (+1), 7 (+2), 9(+3), 12(+4), 16 (+5).";


// -- 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");
}

