 function cambiafoglio(quale){
  //imposta un cookie con il numero del foglio di stile scelto	
  strCookie = "cambiafoglio=" + quale;
  scadenza = new Date();
  scadenza.setFullYear(scadenza.getFullYear()+1);
  strCookie += "; expires=" + scadenza.toGMTString();
  document.cookie = strCookie;
  //rende attivo il foglio di stile corrispondente alla scelta effettuata	
  quale=quale-1;
  if(document.styleSheets){
    var c = document.styleSheets.length;
    for(var i=0;i<c-1;i++){
      if(i!=quale && document.styleSheets[i].href.indexOf('it.css')==-1 && document.styleSheets[i].href.indexOf('eng.css')==-1){
        document.styleSheets[i].disabled=true;
		//alert(document.styleSheets[i].href + " disabilitato");
      }else{
        document.styleSheets[i].disabled=false;
		//alert(document.styleSheets[i].href + " abilitato");
      }
    }
  }
}
// legge il cookie precedentemente archiviato 
//(grazie a PPK: http://www.quirksmode.org/js/cookies.html)
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
//al caricamento della pagina vede se c'è un cookie che memorizza la dimensione dei caratteri
function leggicookie() {
  var quale = parseInt(readCookie('cambiafoglio'));	
  if (quale) {cambiafoglio(quale);}
}
onload = function(){ leggicookie(); }