// -- AUTHOR: Filippo Spadaro
// -- PROGRAMMER: Filippo Spadaro
// -- LASTREVIEW: 12 maggio 2001 
// -- SITE URL: http://www.geocities.com/nienteperniente

// -- rmbr: sostituire **test.js nelle importazioni JScript dei file HTML
path = "02test.html";
path_fine = "02test_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 r = new Array();

var pA = new Array();
var pB = new Array();
var pC = new Array();
var pD = new Array();


// -- NB: l'utente deve riempire solo i campi:
// -- txt*[*], t[*], r[*], p*[*]
// -- * --
txtA[0]="Tallin";
txtB[0]="Minsk";
txtC[0]="Helsinki";
txtD[0]="Sarajevo";
t[0]="La capitale della Bosnia-Erzegovina è:<BR>" + txtA[0] + ", " + txtB[0] + ", " + txtC[0] + ", " + txtD[0] + ".";
r[0]=txtD[0];
pA[0]=0;pB[0]=0;pC[0]=0;pD[0]=1;

// -- * --
txtA[1]="russo";
txtB[1]="francese";
txtC[1]="inglese";
txtD[1]="gallese";
t[1]="La lingua che si parla in Francia:<BR>" + txtA[1] + ", " + txtB[1] + ", " + txtC[1] + ", " + txtD[1] + ".";
r[1]=txtB[1];
pA[1]=0;pB[1]=1;pC[1]=0;pD[1]=0;

// -- * --
txtA[2]="peseta";
txtB[2]="lira";
txtC[2]="marco";
txtD[2]="franco";
t[2]= "Qual era la moneta nazionale della Germania prima dell'arrivo dell'euro:<BR>" + txtA[2] + ", " + txtB[2] + ", " + txtC[2] + ", " + txtD[2] + "?";
r[2]=txtC[2];
pA[2]=0;pB[2]=0;pC[2]=1;pD[2]=0;

// -- * --
txtA[3]="503 Km";
txtB[3]="4220 Km";
txtC[3]="1292 Km";
txtD[3]="11651 Km";
t[3]= "Quanti chilometri è l'itinerario Milano - (Ginevra - Parigi) - Londra:<BR>" + txtA[3] + ", " + txtB[3] + ", " + txtC[3] + ", " + txtD[3] + "?";
r[3]=txtC[3];
pA[3]=0;pB[3]=0;pC[3]=1;pD[3]=0;

// -- * --
txtA[4]="protestante";
txtB[4]="ortodossa";
txtC[4]="cattolica";
txtD[4]="evangelica";
t[4]= "Religione predominante in Irlanda:<BR>" + txtA[4] + ", " + txtB[4] + ", " + txtC[4] + ", " + txtD[4] + ".";
r[4]= txtC[4];
pA[4]=0;pB[4]=0;pC[4]=1;pD[4]=0;

// -- * --
txtA[5]="503 Km";
txtB[5]="781 Km";
txtC[5]="9992 Km";
txtD[5]="11651 Km";
t[5]= "Quanti chilometri è l'itinerario Milano - (Losanna) - Lussemburgo:<BR>" + txtA[5] + ", " + txtB[5] + ", " + txtC[5] + ", " + txtD[5] + "?";
r[5]= txtB[5];
pA[5]=0;pB[5]=1;pC[5]=0;pD[5]=0;

// -- * --
txtA[6]="Tallin";
txtB[6]="Praga";
txtC[6]="Copenaghen";
txtD[6]="Sarajevo";
t[6]= "La capitale della Danimarca è:<BR>" + txtA[6] + ", " + txtB[6] + ", " + txtC[6] + ", " + txtD[6] + ".";
r[6]= txtC[6];
pA[6]=0;pB[6]=0;pC[6]=1;pD[6]=0;

// -- * --
txtA[7]="Tallin";
txtB[7]="Praga";
txtC[7]="Sofia";
txtD[7]="Sarajevo";
t[7]= "La capitale della Bulgaria è:<BR>" + txtA[7] + ", " + txtB[7] + ", " + txtC[7] + ", " + txtD[7] + ".";
r[7]= txtC[7];
pA[7]=0;pB[7]=0;pC[7]=1;pD[7]=0;

// -- * --
txtA[8]="Austria";
txtB[8]="Francia";
txtC[8]="Croazia";
txtD[8]="Slovenia";
t[8]= "Con quale di questi stati non confina l'Italia:<BR>" + txtA[8] + ", " + txtB[8] + ", " + txtC[8] + ", " + txtD[8] + ".";
r[8]= txtC[8];
pA[8]=0;pB[8]=0;pC[8]=1;pD[8]=0;

// -- * --
txtA[9]="Trentino";
txtB[9]="Veneto";
txtC[9]="Friuli Venezia Giulia";
txtD[9]="Lombardia";
t[9]= "In quale regione italiana si trova Treviso:<BR>" + txtA[9] + ", " + txtB[9] + ", " + txtC[9] + ", " + txtD[9] + ".";
r[9]= txtB[9];
pA[9]=0;pB[9]=1;pC[9]=0;pD[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[i].elements[0].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");
}

