// -- AUTHOR: Filippo Spadaro
// -- PROGRAMMER: Filippo Spadaro
// -- LASTREVIEW: 13 aprile 2002
// -- SITE URL: http://www.geocities.com/nienteperniente

// -- rmbr: sostituire **test.js nelle importazioni JScript dei file HTML
path = "08test.html";
path_fine = "08test_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]="In Italia";
txtB[0]="In Svizzera";
txtC[0]="Nel loro stato d'origine";
txtD[0]="Non verranno seppelliti";
txtE[0]="Su un territorio neutrale";
t[0]="Un aereo precipita sul confine italo-svizzero schiantandosi al suolo. Dove verranno seppeliti i superstiti?";
r[0]=txtD[0] + ",&nbsp;in quanto sono superstiti!";
pA[0]=0;pB[0]=0;pC[0]=0;pD[0]=1;pE[0]=0;

// -- * --
txtA[1]="Sì";
txtB[1]="No";
txtC[1]="Ogni 2 anni";
txtD[1]="Non più dal 1895";
txtE[1]="Dal 1895 in poi";
t[1]="Oltre che negli USA, hanno il 4 di luglio anche in Inghilterra?";
r[1]=txtA[1] + ", il giorno dopo il 3 di luglio!";
pA[1]=1;pB[1]=0;pC[1]=0;pD[1]=0;pE[1]=0;

// -- * --
txtA[2]="Ottobre";
txtB[2]="Settembre";
txtC[2]="Agosto";
txtD[2]="Febbraio";
txtE[2]="Gennaio";
t[2]= "Qual è il mese in cui i tedeschi bevono meno birra?";
r[2]=txtD[2] + "&nbsp;perché ha solo 28 giorni.";
pA[2]=0;pB[2]=0;pC[2]=0;pD[2]=1;pE[2]=0;

// -- * --
txtA[3]="Sì";
txtB[3]="No";
txtC[3]="Non più dal 1950";
txtD[3]="Sì, fin dalla costituzione del Regno d'Italia";
txtE[3]="Sì, solo con l'avvento della Repubblica italiana";
t[3]= "È legale per un italiano sposare la sorella della propria vedova?";
r[3]=txtB[3] + "&nbsp;...perché è morto!";
pA[3]=0;pB[3]=1;pC[3]=0;pD[3]=0;pE[3]=0;

// -- * --
txtA[4]="10";
txtB[4]="25";
txtC[4]="50";
txtD[4]="70";
txtE[4]="90";
t[4]= "Dividi 30 per 1/2 e aggiungi 10. Quanto fa?";
r[4]= txtD[4] + "&nbsp;...30 diviso 1/2 dà 60.";
pA[4]=0;pB[4]=0;pC[4]=0;pD[4]=1;pE[4]=0;

// -- * --
txtA[5]="1";
txtB[5]="2";
txtC[5]="3";
txtD[5]="4";
txtE[5]="5";
t[5]= "Se ci sono 5 mele e ne porti via 2, quante mele hai?";
r[5]= txtB[5] + "&nbsp;...sono proprio quelle che hai preso!";
pA[5]=0;pB[5]=1;pC[5]=0;pD[5]=0;pE[5]=0;

// -- * --
txtA[6]="30";
txtB[6]="45";
txtC[6]="60";
txtD[6]="90";
txtE[6]="105";
t[6]= "Il dottore ti prescrive di prendere 3 pillole, una ogni mezz'ora. Dopo quanti minuti le avrai prese tutte e 3?";
r[6]= txtC[6] + "&nbsp;...prendi subito la prima pillola, 30 minuti dopo ti tocca la seconda e allo scoccare dei 60 minuti la terza.";
pA[6]=0;pB[6]=0;pC[6]=1;pD[6]=0;pE[6]=0;

// -- * --
txtA[7]="1";
txtB[7]="2";
txtC[7]="6";
txtD[7]="9";
txtE[7]="12";
t[7]= "Alcuni mesi all'anno hanno 31 giorni, quanti ne hanno 28?";
r[7]= txtE[7] + ", tutti!";
pA[7]=0;pB[7]=0;pC[7]=0;pD[7]=0;pE[7]=1;

// -- * --
txtA[8]="1";
txtB[8]="5";
txtC[8]="8";
txtD[8]="9";
txtE[8]="17";
t[8]= "Un contadino ha 17 pecore e tutte tranne 9 muoiono, quante ne sopravvivono?";
r[8]= txtD[8] + "&nbsp;...sono proprio quelle che non muoiono!";
pA[8]=0;pB[8]=0;pC[8]=0;pD[8]=1;pE[8]=0;

// -- * --
txtA[9]="0";
txtB[9]="1";
txtC[9]="2";
txtD[9]="4";
txtE[9]="Tutti gli animali del creato!";
t[9]= "Quanti animali per ogni diversa specie Mosè portò sull'Arca?";
r[9]= txtA[9] + "&nbsp;...l'arca di Mosè non fu costruita per ospitare animali, quella fu l'arca di Noè!";
pA[9]=1;pB[9]=0;pC[9]=0;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");
}

