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 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('GommaLayoutCBackgroundColor',color,365); 
} 
}


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');
	var tipo = "ClasseMenuA"; //default
	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('GommaLayoutJerryMod',iddi,365);
}
}

function Rompi(salsa){
var body = document.getElementsByTagName ('p');
var sugo = "ColonneA"; //Default
if (salsa == 1) sugo = "ColonneA";
if (salsa == 2) sugo = "ColonneB";
if (salsa == 3) sugo = "ColonneC";
if (salsa == 4) sugo = "ColonneD";
if (salsa == 5) sugo = "ColonneE";
if (salsa == 6) sugo = "ColonneF";
if (salsa == 7) sugo = "ColonneG";
if (salsa == 8) sugo = "ColonneH";
if (salsa == 9) sugo = "ColonneI";
if (salsa == 10) sugo = "ColonneL";
if (salsa == 11) sugo = "ColonneM";
if (salsa == 12) sugo = "ColonneN";
if (salsa == 13) sugo = "ColonneO";
if (salsa == 14) sugo = "ColonneP";
 for(i=0;i<body.length;i++){
 body[i].className = sugo;
createCookie('GommaLayoutRompiB',salsa,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 = "90%";
	if (size == 5) percentuale = "120%";
	body.style.fontSize = percentuale;
	createCookie('GommaLayoutCFontSize',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('GommaLayoutCWindowSize',largo,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('GommaLayoutCColoreSfondo',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('GommaLayoutCCarattere',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('GommaLayoutDennisMostraScelte',display,365);
}



window.onload = function() {

size = readCookie('GommaLayoutCFontSize');
largo = readCookie('GommaLayoutCWindowSize');
color = readCookie('GommaLayoutCBackgroundColor');
colore = readCookie('GommaLayoutCColoreSfondo');
family = readCookie('GommaLayoutCCarattere');
display = readCookie('GommaLayoutDennisMostraScelte');
salsa = readCookie('GommaLayoutRompiB');
iddi = readCookie('GommaLayoutJerryMod');
Rompi(salsa);
	//indice = readCookie('GommaLayoutCCambia')?indice = readCookie('GommaLayoutCCambia'):ColonneA;
/*	tipo=""; 
if(readCookie('GommaLayoutCMod')!=null
){ 
tipo=readCookie('GommaLayoutCCMod') 
} 
else{ 
tipo=ClasseMenuA
}
*/
/*
tipo=""; 
if(readCookie('GommaLayoutJerryMod')!=null
){ 
indice=readCookie('GommaLayoutJerryMod') 
} 
else{ 
indice=classi[0]
}
*/

	//tipo = readCookie('GommaLayoutJerryMod')?tipo = readCookie('GommaLayoutJerryMod'):ClasseMenuA;
Mod(iddi);
setFontSize(size);
setWindowSize(largo);
setBackgroundColor(color);
setColoreSfondo(colore);
setCarattere(family);
setMostraScelte(display);
}