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');
body[4]=document.getElementById('InterruttoreC');
	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 Car(fam) { 
caratteri=new Array('verdana','arial','courier','georgia','garamond',"'lucida console'","'trebuchet ms'",'tahoma',"'11S01 Black Tuesday'",'AddElectricCity','African','AlgerianD','Amano',"'Amelia BT'","'Americana XBd BT'","'AmerType Md BT'",'Aquaduct','Arbeka',"'AvantGarde Bk BT'","'Babylon5 Hollow'","'BankGothic Lt BT'","'Bauhaus Md BT'",'Beatbox','Bedrock','BinnerD','BlackForest','Book Antiqua',"'Bookman Old Style'","'Bremen Blk BT'",'Brisk',"'Brookhouse Heavy'","'CaslonOpnface BT'","'Century Gothic'","'Century725 Blk BT'",'ChiselD',"'Clarendon BT'","'Clarendon Hv BT'","'CloisterBlack BT'","'Comic Sans MS'","'Compacta Blk BT'","'CopprplGoth Hv BT'",'CountdownD',"'Courier New'",'Dunebug','Eklektic',"'EngrvrsOldEng Bd BT'",'EnviroD',"'Exotc350 Lt BT'",'Fixedsys',"'Follies LET'","'Forgotten Futurist'","'FormalScrp421 BT'","'Freefrm721 Blk BT'","'Freehand591 BT'",'FreestyleScrD','Frission',"'FrizQuadrata BT'","'Futura Md BT'",'Future','Galleria',"'Geometr231 BT'","'Geometr885 BT'",'Glacier','GlaserSteD','GoldMine','GoudyOlSt BT','Griffon',"'Hazel LET'",'Honda',"'Humnst777 Lt BT'","'HuxleyVertical BT'",'Impact','INNAsterItalic',"'Jazz LET'","'Kabel Bk BT'","'Kaufmann BT'","'Lady Ice'",'Larabiefont','LatinWidD',"'Lois Ann'","'London Tube'","'Lucida Sans Unicode'","'Millenium BdEx BT'",'Modern',"'Monospac821 BT'","'Orbit-B BT'","'Palatino Linotype'","'ParkAvenue BT'",'Pepper',"'Pioneer BT'",'President',"'Ribbon131 BT'",'Roman','Sanlite',"'Sci Fied 2002'",'Script','SerpentineDBol',"'SF Arborcrest Medium'","'SF Laundromatic'","'SF Old Republic'","'SF Speedwaystar'","'SF Theramin Gothic Shaded'","'SF TransRobotics'","'SF Willamette'",'SquireD',"'Staccato222 BT'",'StopD',"'Swis721 BlkOul BT'","'Swis721 BlkRnd BT'",'Technical','Ultraworld',"'VAGRounded BT'","'Van Dijk'",'Xpressive','Zekton','Zrnic',"'New Aster'")
var body = document.getElementsByTagName('body')[0]; 
body.style.fontFamily = caratteri[fam]; 
createCookie('GommaLayoutCaratterini3',fam,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);
}

function Vecchi(mostra) {
	var body = document.getElementById('VecchieVersioni');
	var vedi = "none"; // default
	if (mostra == 1) vedi = "none";
	if (mostra== 2) vedi = "block";
	body.style.display = vedi;
	createCookie('GommaLayoutVecchi',mostra,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');
body[5]=document.getElementById('InterruttoreA');
body[6]=document.getElementById('VecchieVersioni');
body[7]=document.getElementById('SottoVoci');
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('GommaLayoutSfondo',color,365); 
}
}


window.onload = function() {

size = readCookie('GommaLayoutCFontSize');
largo = readCookie('GommaLayoutCWindowSize');
color = readCookie('GommaLayoutSfondo');
colore = readCookie('GommaLayoutCColoreSfondo');
fam = (readCookie('GommaLayoutCaratterini3')? readCookie('GommaLayoutCaratterini3'):0);
display = readCookie('GommaLayoutDennisMostraScelte');
salsa = readCookie('GommaLayoutRompiB');
iddi = readCookie('GommaLayoutJerryMod');
mostra = readCookie('GommaLayoutVecchi');
Rompi(salsa);
Mod(iddi);
setFontSize(size);
setWindowSize(largo);
setBackgroundColor(color);
setColoreSfondo(colore);
Car(fam);
setMostraScelte(display);
Vecchi(mostra);
}