ok = (document.styleSheets) ? 1 : 0;

IE = ((ind1 = navigator.appVersion.indexOf("MSIE")) > -1) ? 1 : 0;
IE4 = (IE && document.all) ? 1:0;

NN = (navigator.appName.indexOf("Netscape")>-1) ? 1 : 0;
NN4 = (NN && document.layers) ? 1 : 0;
NN6 = (NN && document.getElementById) ? 1:0;

if(ok) 
{
  if(IE4) stile = document.styleSheets[0].rules
  if(NN6) stile = document.styleSheets[0].cssRules 
}

function cambiaTesto() {
	size2="";
	size3="";
	size4="";
	//i = document.form.dimensione.selectedIndex;
	size = document.form.dimensione.options[document.form.dimensione.selectedIndex].value;

	if (size == 0)
	{
		//alert("Seleziona un valore");
		//javascript:location.reload();
	}
	else
	{
		if (size == 18) 
		{
			size2 = 20;
			size3 = 16;
			size4 = 22;
		}
		else if (size == 20) 
		{
			size2 = 22;
			size3 = 18;
			size4 = 24;
		}
		else if (size == 22) 
		{
			size2 = 24;
			size3 = 20;
			size4 = 26;
		}
		else if (size == 24) 
		{
		size2 = 26;
		size3 = 22;
		size4 = 28;
		}
		if(ok)
		{
  		stile[0].style.fontSize = size;
		stile[1].style.fontSize = size2;
		stile[2].style.fontSize = size;
		stile[3].style.fontSize = size3;
		stile[4].style.fontSize = size3;
		stile[5].style.fontSize = size4;
		stile[6].style.fontSize = size2;
		//stile[7].style.fontSize = size2;
		stile[8].style.fontSize = size2;
		stile[9].style.fontSize = size;
		stile[10].style.fontSize = size;
		stile[11].style.fontSize = size;
		stile[12].style.fontSize = size;
		stile[13].style.fontSize = size;
  		//stile[0].style.color = "red";
  		//stile[0].style.backgroundColor = "blue";
		}
		else
  		alert("l'oggetto styleSheets\nNON\nč supportato")
	}

	//i = document.form.dimensione.selectedIndex;
colore = document.form.sfondo.options[document.form.sfondo.selectedIndex].value;

if (colore == 0)
{
	//javascript:location.reload();
	//alert("Seleziona un valore");
	
}
else
{
	if (colore == 1)
	{ 
		if(ok)
		{
  			stile[0].style.backgroundColor = "black";
			stile[0].style.color = "white";
			
			stile[1].style.backgroundColor = "black";
			stile[1].style.color = "white";
			
			stile[2].style.backgroundColor = "black";
			stile[2].style.color = "white";
			
			stile[3].style.backgroundColor = "black";
			stile[3].style.color = "white";
			
			stile[4].style.backgroundColor = "black";
			stile[4].style.color = "white";
			
			stile[5].style.backgroundColor = "black";
			stile[5].style.color = "white";
			
			stile[6].style.backgroundColor = "black";
			stile[6].style.color = "white";
			
			stile[7].style.backgroundColor = "black";
			stile[7].style.color = "white";
			
			stile[8].style.backgroundColor = "black";
			stile[8].style.color = "white";
			
			stile[9].style.backgroundColor = "black";
			stile[9].style.color = "white";
			
			stile[10].style.backgroundColor = "black";
			stile[10].style.color = "white";
			
			stile[11].style.backgroundColor = "black";
			stile[11].style.color = "white";
			
			stile[12].style.backgroundColor = "black";
			stile[12].style.color = "white";
			
			stile[13].style.backgroundColor = "black";
			stile[13].style.color = "white";
			
  			//stile[0].style.color = "red";
  			//stile[0].style.backgroundColor = "blue";
		}
		else
  		alert("l'oggetto styleSheets\nNON\nč supportato")
	}
	else if (colore == 2)
	{ 
		stile[0].style.color = "black";
		stile[0].style.backgroundColor = "white";
		
		stile[1].style.color = "black";
		stile[1].style.backgroundColor = "white";
		
		stile[2].style.color = "black";
		stile[2].style.backgroundColor = "white";
		
		stile[3].style.color = "black";
		stile[3].style.backgroundColor = "white";
		
		stile[4].style.color = "black";
		stile[4].style.backgroundColor = "white";
		
		stile[5].style.color = "black";
		stile[5].style.backgroundColor = "white";
		
		stile[6].style.color = "black";
		stile[6].style.backgroundColor = "white";
		
		stile[7].style.color = "black";
		stile[7].style.backgroundColor = "white";
		
		stile[8].style.color = "black";
		stile[8].style.backgroundColor = "white";
		
		stile[9].style.color = "black";
		stile[9].style.backgroundColor = "white";
		
		stile[10].style.color = "black";
		stile[10].style.backgroundColor = "white";
		
		stile[11].style.color = "black";
		stile[11].style.backgroundColor = "white";

		stile[12].style.color = "black";
		stile[12].style.backgroundColor = "white";
		
		stile[13].style.color = "black";
		stile[13].style.backgroundColor = "white";
		
	}
	
}
SetCooKie(size, colore);
}

function SetCooKie(size, colore) {
   	var today = new Date();  // data/orario di oggi
   	var expires = new Date();  // variabile necessaria a calcolare la scadenza
	
   expires.setTime(today.getTime() + (1000*60*60*24)); // fra 24 ore in millisecondi  
   document.cookie="size=" + size + ";  expires=" + expires.toGMTString() + "; path=/;"// attivo il cookie
   document.cookie="colore="+ colore+ "; expires=" + expires.toGMTString() + "; path=/;"// attivo il cookie
   //alert(size);  //alert di controllo dei contenuti
   //alert(colore);
}

function readCookie(){
	var tutti=document.cookie; //--legge la proprietā cookie-- 
	var cook=tutti.indexOf("size="); //--cerca l'inizio del cookie di nome pippo-- 
	if(cook != -1){ 
		var aa= cook +5; //--inizio valore cookie-- 
		var zz=tutti.indexOf(";", cook); //--fine valore cookie-- 
		if(zz== -1) zz=tutti.length; 
		var valore=tutti.substring(aa, zz); //--estrazione del valore-- 
		valore=unescape(valore); //--decodifica-- 
		//alert(valore); //--Verifichiamo che il valore estratto corrisponda-- 
	}
	var tutti2=document.cookie; //--legge la proprietā cookie-- 
	var cook2=tutti2.indexOf("colore="); //--cerca l'inizio del cookie di nome pippo-- 
	if(cook2 != -1){ 
	var aa2= cook2 +7; //--inizio valore cookie-- 
	var zz2=tutti.indexOf(";", cook2); //--fine valore cookie-- 
	if(zz2== -1) zz2=tutti2.length; 
	var valore2=tutti2.substring(aa2, zz2); //--estrazione del valore-- 
	valore2=unescape(valore2); //--decodifica-- 
	//alert(valore2); //--Verifichiamo che il valore estratto corrisponda-- 
	}  
	settaPreferenze(valore, valore2)
}

function settaPreferenze(size, colore) {
size2="";
size3="";
size4="";
//i = document.form.dimensione.selectedIndex;

if (size == 0)
{
	//alert("Seleziona un valore");
	//javascript:location.reload();
}
else
{
	if (size == 18) 
	{
		size2 = 20;
		size3 = 16;
		size4 = 22;
	}
	else if (size == 20) 
	{
		size2 = 22;
		size3 = 18;
		size4 = 24;
	}
	else if (size == 22) 
	{
		size2 = 24;
		size3 = 20;
		size4 = 26;
	}
	else if (size == 24) 
	{
		size2 = 26;
		size3 = 22;
		size4 = 28;
	}
	
  	stile[0].style.fontSize = size;
	stile[1].style.fontSize = size2;
	stile[2].style.fontSize = size;
	stile[3].style.fontSize = size3;
	stile[4].style.fontSize = size3;
	stile[5].style.fontSize = size4;
	stile[6].style.fontSize = size2;
	//stile[7].style.fontSize = size2;
	stile[8].style.fontSize = size2;
	stile[9].style.fontSize = size;
	stile[10].style.fontSize = size;
	stile[11].style.fontSize = size;
	stile[12].style.fontSize = size;
	stile[13].style.fontSize = size;
  	//stile[0].style.color = "red";
  	//stile[0].style.backgroundColor = "blue";
	}

if (colore == 0)
{
	//javascript:location.reload();
	//alert("Seleziona un valore");
	
}
else
{
	if (colore == 1)
	{ 
  			stile[0].style.backgroundColor = "black";
			stile[0].style.color = "white";
			
			stile[1].style.backgroundColor = "black";
			stile[1].style.color = "white";
			
			stile[2].style.backgroundColor = "black";
			stile[2].style.color = "white";
			
			stile[3].style.backgroundColor = "black";
			stile[3].style.color = "white";
			
			stile[4].style.backgroundColor = "black";
			stile[4].style.color = "white";
			
			stile[5].style.backgroundColor = "black";
			stile[5].style.color = "white";
			
			stile[6].style.backgroundColor = "black";
			stile[6].style.color = "white";
			
			stile[7].style.backgroundColor = "black";
			stile[7].style.color = "white";
			
			stile[8].style.backgroundColor = "black";
			stile[8].style.color = "white";
			
			stile[9].style.backgroundColor = "black";
			stile[9].style.color = "white";
			
			stile[10].style.backgroundColor = "black";
			stile[10].style.color = "white";
			
			stile[11].style.backgroundColor = "black";
			stile[11].style.color = "white";
			
			stile[12].style.backgroundColor = "black";
			stile[12].style.color = "white";
			
			stile[13].style.backgroundColor = "black";
			stile[13].style.color = "white";
			
  			//stile[0].style.color = "red";
  			//stile[0].style.backgroundColor = "blue";
		}
		
	else if (colore == 2)
	{ 
		stile[0].style.color = "black";
		stile[0].style.backgroundColor = "white";
		
		stile[1].style.color = "black";
		stile[1].style.backgroundColor = "white";
		
		stile[2].style.color = "black";
		stile[2].style.backgroundColor = "white";
		
		stile[3].style.color = "black";
		stile[3].style.backgroundColor = "white";
		
		stile[4].style.color = "black";
		stile[4].style.backgroundColor = "white";
		
		stile[5].style.color = "black";
		stile[5].style.backgroundColor = "white";
		
		stile[6].style.color = "black";
		stile[6].style.backgroundColor = "white";
		
		stile[7].style.color = "black";
		stile[7].style.backgroundColor = "white";
		
		stile[8].style.color = "black";
		stile[8].style.backgroundColor = "white";
		
		stile[9].style.color = "black";
		stile[9].style.backgroundColor = "white";
		
		stile[10].style.color = "black";
		stile[10].style.backgroundColor = "white";
		
		stile[11].style.color = "black";
		stile[11].style.backgroundColor = "white";

		stile[12].style.color = "black";
		stile[12].style.backgroundColor = "white";
		
		stile[13].style.color = "black";
		stile[13].style.backgroundColor = "white";
		
	}
	
}
}


function numeroFogli(){
msg = "";
if(ok)
  msg +="document.styleSheets.length = "+document.styleSheets.length
else msg = "l'oggetto styleSheets\nNON\nč supportato";
alert(msg)
}