function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = '; expires='+date.toGMTString();
}
else expires = '';
document.cookie = name+'='+value+expires+'; path=/';
}
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;
}
function Mod(iddi){
	var body=new Array(); 
body[0]=document.getElementById('Menu'); 
body[1]=document.getElementById('InterruttoreA');
body[2]=document.getElementById('InterruttoreB');
body[3]=document.getElementById('Piede');
	if (iddi == 1) tipo = "ClasseMenuA";
	if (iddi == 2) tipo = "ClasseMenuB";
	if (iddi == 3) tipo = "ClasseMenuC";
	if (iddi == 4) tipo = "ClasseMenuD";
	if (iddi == 5) tipo = "ClasseMenuE";
	if (iddi == 6) tipo = "ClasseMenuF";
	if (iddi == 7) tipo = "ClasseMenuG";
	if (iddi == 8) tipo = "ClasseMenuH";
	if (iddi == 9) tipo = "ClasseMenuI";
	if (iddi == 10) tipo = "ClasseMenuL";
	if (iddi == 11) tipo = "ClasseMenuM";
	if (iddi == 12) tipo = "ClasseMenuN";
	if (iddi == 13) tipo = "ClasseMenuO";
	if (iddi == 14) tipo = "ClasseMenuP";
	for(i=0;i<body.length;i++){ 
	body[i].className = tipo;				
	createCookie('GommaLayoutBMod',tipo,365);
}
}
var classi= new Array('ColonneA', 'ColonneB', 'ColonneC', 'ColonneD', 'ColonneE', 'ColonneF', 'ColonneG', 'ColonneH', 'ColonneI', 'ColonneL', 'ColonneM', 'ColonneN', 'ColonneO', 'ColonneP')
//inserendo qui puoi usare questo array in tutte le funzioni
function Cambia(indice){
var elementi =  document.getElementsByTagName ('p')
for(i=0;i<elementi.length;i++){
elementi[i].className = classi[indice];
createCookie('GommaLayoutBCambia',indice,365);
 }
}
function setFontSize(size) {
	var body = document.getElementsByTagName('body')[0];
	var percentuale = "75%"; // default
	if (size == 1) percentuale = "50%";
	if (size == 2) percentuale = "65%";
	if (size == 3) percentuale = "75%";
	if (size == 4) percentuale = "80%";
	if (size == 5) percentuale = "90%";	
	if (size == 6) percentuale = "100%";
	if (size == 7) percentuale = "120%";
	body.style.fontSize = percentuale;
	createCookie('GommaLayoutBFontSize',size,365);
}
function setWindowSize(largo) {
	var body = document.getElementById('Contenitore');
	var percentuale = "76%"; // default
	if (largo == 1) percentuale = "58%";
	if (largo == 2) percentuale = "68%";
	if (largo == 3) percentuale = "76%";
	if (largo == 4) percentuale = "90%";
	if (largo == 5) percentuale = "100%";	
	if (largo == 6) percentuale = "500px";
	if (largo == 7) percentuale = "620px";
	if (largo == 8) percentuale = "760px";
	if (largo == 9) percentuale = "900px";
	if (largo == 10) percentuale = "1100px";
	body.style.width = percentuale;
	createCookie('GommaLayoutBWindowSize',largo,365);
}
function setBackgroundColor(color) { 
var body=new Array(); 
body[0]=document.getElementById('SottoMenu'); 
body[1]=document.getElementById('XMenu');
body[2]=document.getElementById('BordinoSopra');
body[3]=document.getElementById('BordinoSotto');
body[4]=document.getElementById('Impostazioni');
var background = "#FF6C6C"; // default 
if (color == 1) background = "#D96482";
if (color == 2) background = "#8E4071"; 
if (color == 3) background = "#E21B75"; 
if (color == 4) background = "#FF6C6C";
if (color == 5) background = "#F0B842";
if (color == 6) background = "#89B3FE";
if (color == 7) background = "#4B86E7";
if (color == 8) background = "#5C74C5";
if (color == 9) background = "#A099FF";
if (color == 10) background = "#52A7AD";
if (color == 11) background = "#66CCCC";
if (color == 12) background = "#D7D8C7";
if (color == 13) background = "#E9D0BA";
if (color == 14) background = "#F9E8C8";
for(i=0;i<body.length;i++){ 
body[i].style.backgroundColor = background;
createCookie('GommaLayoutBBackgroundColor',color,365); 
} 
}
function setColoreSfondo(colore) { 
var body=new Array(); 
body[0]=document.getElementById('Xh1'); 
body[1]=document.getElementById('Testata'); 
body[2]=document.getElementById('Xh2');
body[3]=document.getElementById('Menu');
var background = "#FF6C6C"; // default 
if (colore == 1) background = "#D96482";
if (colore == 2) background = "#8E4071"; 
if (colore == 3) background = "#E21B75"; 
if (colore == 4) background = "#FF6C6C";
if (colore == 5) background = "#F0B842";
if (colore == 6) background = "#89B3FE";
if (colore == 7) background = "#4B86E7";
if (colore == 8) background = "#5C74C5";
if (colore == 9) background = "#A099FF";
if (colore == 10) background = "#52A7AD";
if (colore == 11) background = "#66CCCC";
if (colore == 12) background = "#D7D8C7";
if (colore == 13) background = "#E9D0BA";
if (colore == 14) background = "#F9E8C8";
for(i=0;i<body.length;i++){ 
body[i].style.backgroundColor = background;
createCookie('GommaLayoutBColoreSfondo',colore,365); 
} 
}
function setCarattere(family) {
	var body = document.getElementsByTagName('body')[0];
	var carattere = "verdana"; // default
	if (family == 1) carattere = "verdana";
	if (family == 2) carattere = "arial";
	if (family == 3) carattere = "courier";
	if (family == 4) carattere = "georgia";
	if (family == 5) carattere = "garamond";
	if (family == 6) carattere = "'lucida console'";
	if (family == 7) carattere = "'trebuchet ms'";
	if (family == 8) carattere = "'tahoma'";
	body.style.fontFamily = carattere;
	createCookie('GommaLayoutBCarattere',family,365);
}

function setMostraScelte(display) {
	var body = document.getElementById('Impostazioni');
	var visualizza = "none"; // default
	if (display == 1) visualizza = "none";
	if (display== 2) visualizza = "block";
	body.style.display = visualizza;
	createCookie('GommaLayoutBMostraScelte',display,365);
}
window.onload = function() {
	size = readCookie('GommaLayoutBFontSize');
	largo = readCookie('GommaLayoutBWindowSize');
	color = readCookie('GommaLayoutBBackgroundColor');
	colore = readCookie('GommaLayoutBColoreSfondo');
	family = readCookie('GommaLayoutBCarattere');
	display = readCookie('GommaLayoutBMostraScelte');
	indice = readCookie('GommaLayoutBCambia')?indice = readCookie('GommaLayoutBCambia'):ColonneA;
	tipo = readCookie('GommaLayoutBMod')?tipo = readCookie('GommaLayoutBMod'):ClasseMenuA;
	Mod(tipo);
	Cambia(indice);
	setFontSize(size);
	setWindowSize(largo);
	setBackgroundColor(color);
	setColoreSfondo(colore);
	setCarattere(family);
	setMostraScelte(display);
}