var style_props = new Object();
style_props["css/textmedium.css"] = "testo medio";
style_props["css/textlarge.css"] = "testo grande";
style_props["css/textsmall.css"] = "testo piccolo";

style_props["css/layoutmedium.css"] = "pagina media";
style_props["css/layoutnarrow.css"] = "pagina stretta";
style_props["css/layoutwide.css"] = "pagina larga";

style_props["css/default.css"] = "stile blu";
style_props["css/highcontrast.css"] = "stile chiaro";
style_props["css/darkcontrast.css"] = "stile scuro";
style_props["css/autumn.css"] = "stile autunno";
style_props["css/beer.css"] = "stile birra";
style_props["css/berries.css"] = "stile frutti di bosco";
style_props["css/green.css"] = "stile verde";
style_props["css/orange.css"] = "stile arancio";
style_props["css/winter.css"] = "stile invernale";
style_props["css/spring.css"] = "stile primaverile";
style_props["css/grey.css"] = "stile grigio";
style_props["css/redwhite.css"] = "stile rosso";

style_props["css/menuposition_left.css"] = "menu a sinistra";
style_props["css/menuposition_right.css"] = "menu a destra";

style_props["css/fontarial.css"] = "Arial";
style_props["css/fontgeorgia.css"] = "Georgia";
style_props["css/fonttimes.css"] = "Times";
style_props["css/fonttrebuchet.css"] = "Trebuchet";
style_props["css/fontverdana.css"] = "Verdana";

var stylesheets = new Object();
stylesheets["textsize"] = 0;
stylesheets["layoutsize"] = 1;
stylesheets["pagestyle"] = 2;
stylesheets["menuposition"] = 3;
stylesheets["font"] = 4;

function style_initialize() {
var alink = document.getElementById("cambiastile");
alink.onclick = function() { showpopup(); return(false);};
}

function showpopup() {

var currentstyle = style_props[js_globalstyle["layoutsize"]] + ", " + style_props[js_globalstyle["textsize"]] + ", " + style_props[js_globalstyle["font"]] + ", " + style_props[js_globalstyle["pagestyle"]] + ", " + style_props[js_globalstyle["menuposition"]] + "."; 

var headerdiv = document.getElementById("header_top");
var firstdiv = document.getElementById("header_leftcol");
var popupdiv = document.createElement("div");
popupdiv.id = "header_popup";
var closediv = document.createElement("div");
var closelink = document.createElement("a");
closelink.href="#";
closelink.onclick = function() { hidepopup(); return(false);};
var closetxt = document.createTextNode("chiudi");
closelink.appendChild(closetxt);
closediv.appendChild(closelink);
popupdiv.appendChild(closediv);

var div_curr = document.createElement("p");
div_curr.id = "header_popup_current";
var div_curr_txt = document.createTextNode("stile attuale: " + currentstyle);
div_curr.appendChild(div_curr_txt);
popupdiv.appendChild(div_curr);

var ul = document.createElement("ul");
popupdiv.appendChild(ul);

var li1 = document.createElement("li");
var li1txt = document.createTextNode("dimensione testo: ");
li1.appendChild(li1txt);
var li1a1 = document.createElement("a");
li1a1.href="#";
li1a1.onclick = function() { changecss('textsize','css/textsmall.css'); return(false);};
var li1a1txt = document.createTextNode("piccola");
li1a1.appendChild(li1a1txt);
li1.appendChild(li1a1);
var separatore = document.createTextNode(" | ");
li1.appendChild(separatore);

var li1a2 = document.createElement("a");
li1a2.href="#";
li1a2.onclick = function() { changecss('textsize','css/textmedium.css'); return(false);};
var li1a2txt = document.createTextNode("media");
li1a2.appendChild(li1a2txt);
li1.appendChild(li1a2);
var separatore2 = document.createTextNode(" | ");
li1.appendChild(separatore2);

var li1a3 = document.createElement("a");
li1a3.href="#";
li1a3.onclick = function() { changecss('textsize','css/textlarge.css'); return(false);};
var li1a3txt = document.createTextNode("grande");
li1a3.appendChild(li1a3txt);
li1.appendChild(li1a3);
ul.appendChild(li1);

var li4 = document.createElement('li');
var li4txt = document.createTextNode('font: ');
li4.appendChild(li4txt);
var drop2 = document.createElement('select');
drop2.id = "header_popup_select2";
drop2.onchange = new Function('setdropcss2();');
var opt0f = document.createElement('option');
opt0f.value = "css/fontarial.css";
var opt0ftext = document.createTextNode('Seleziona un font dalla lista');
opt0f.appendChild(opt0ftext);
drop2.appendChild(opt0f);

var opt1f = document.createElement('option');
opt1f.value = "css/fontarial.css";
opt1f.style.fontFamily = "Arial";
var opt1ftext = document.createTextNode('Arial, sans serif');
opt1f.appendChild(opt1ftext);
drop2.appendChild(opt1f);

var opt2f = document.createElement('option');
opt2f.value = "css/fontgeorgia.css";
opt2f.style.fontFamily = "Georgia";
var opt2ftext = document.createTextNode('Georgia, sans serif');
opt2f.appendChild(opt2ftext);
drop2.appendChild(opt2f);

var opt3f = document.createElement('option');
opt3f.value = "css/fonttimes.css";
opt3f.style.fontFamily = "Times New Roman";
var opt3ftext = document.createTextNode('Times, serif');
opt3f.appendChild(opt3ftext);
drop2.appendChild(opt3f);

var opt4f = document.createElement('option');
opt4f.value = "css/fonttrebuchet.css";
opt4f.style.fontFamily = "Trebuchet MS";
var opt4ftext = document.createTextNode('Trebuchet, sans serif (default)');
opt4f.appendChild(opt4ftext);
drop2.appendChild(opt4f);

var opt5f = document.createElement('option');
opt5f.value = "css/fontverdana.css";
opt5f.style.fontFamily = "Verdana";
var opt5ftext = document.createTextNode('Verdana, sans serif');
opt5f.appendChild(opt5ftext);
drop2.appendChild(opt5f);

li4.appendChild(drop2);
ul.appendChild(li4);

// larghezza pagina
var li2 = document.createElement("li");
var li2txt = document.createTextNode("larghezza pagina: ");
li2.appendChild(li2txt);
var li2a1 = document.createElement("a");
li2a1.href="#";
li2a1.onclick = function() { changecss('layoutsize','css/layoutnarrow.css'); return(false);};
var li2a1txt = document.createTextNode("stretta");
li2a1.appendChild(li2a1txt);
li2.appendChild(li2a1);
var li2a1space = document.createTextNode(" | ");
li2.appendChild(li2a1space);

var li2a2 = document.createElement("a");
li2a2.href="#";
li2a2.onclick = function() { changecss('layoutsize','css/layoutmedium.css'); return(false);};
var li2a2txt = document.createTextNode("media");
li2a2.appendChild(li2a2txt);
li2.appendChild(li2a2);
var li2a2space = document.createTextNode(" | ");
li2.appendChild(li2a2space);

var li2a3 = document.createElement("a");
li2a3.href="#";
li2a3.onclick = function() { changecss('layoutsize','css/layoutwide.css'); return(false);};
var li2a3txt = document.createTextNode("larga");
li2a3.appendChild(li2a3txt);
li2.appendChild(li2a3);
ul.appendChild(li2);

var li0 = document.createElement("li");
var li0txt = document.createTextNode("posizione menu: ");
li0.appendChild(li0txt);
var li0a1 = document.createElement("a");
li0a1.href="#";
li0a1.onclick = function() { changecss('menuposition','css/menuposition_left.css'); return(false);};
var li0a1txt = document.createTextNode("sinistra");
li0a1.appendChild(li0a1txt);
li0.appendChild(li0a1);
var li0a1space = document.createTextNode(" | ");
li0.appendChild(li0a1space);

var li0a2 = document.createElement("a");
li0a2.href="#";
li0a2.onclick = function() { changecss('menuposition','css/menuposition_right.css'); return(false);};
var li0a2txt = document.createTextNode("destra");
li0a2.appendChild(li0a2txt);
li0.appendChild(li0a2);
ul.appendChild(li0);


var li3 = document.createElement('li');
var li3txt = document.createTextNode('stile pagina: ');
li3.appendChild(li3txt);
var drop = document.createElement('select');
drop.id = "header_popup_select";
drop.onchange = new Function('setdropcss();');

var opt0 = document.createElement('option');
opt0.value = "css/default.css";
var opt0text = document.createTextNode('Seleziona uno stile dalla lista');
opt0.appendChild(opt0text);
drop.appendChild(opt0);

var opt1 = document.createElement('option');
opt1.value = "css/default.css";
var opt1text = document.createTextNode('azzurro e bianco (default)');
opt1.appendChild(opt1text);
drop.appendChild(opt1);

var opt1l = document.createElement('option');
opt1l.value = "css/redwhite.css";
var opt1ltext = document.createTextNode('rosso e bianco');
opt1l.appendChild(opt1ltext);
drop.appendChild(opt1l);

var opt1h = document.createElement('option');
opt1h.value = "css/grey.css";
var opt1htext = document.createTextNode('grigio elegante');
opt1h.appendChild(opt1htext);
drop.appendChild(opt1h);

var opt1j = document.createElement('option');
opt1j.value = "css/spring.css";
var opt1jtext = document.createTextNode('primavera, verde+giallo');
opt1j.appendChild(opt1jtext);
drop.appendChild(opt1j);

var opt1g = document.createElement('option');
opt1g.value = "css/winter.css";
var opt1gtext = document.createTextNode('invernale, neve+rosso+bianco');
opt1g.appendChild(opt1gtext);
drop.appendChild(opt1g);

var opt1d = document.createElement('option');
opt1d.value = "css/autumn.css";
var opt1dtext = document.createTextNode('autunno, rosso+arancio');
opt1d.appendChild(opt1dtext);
drop.appendChild(opt1d);

var opt1e = document.createElement('option');
opt1e.value = "css/green.css";
var opt1etext = document.createTextNode('verde pallido');
opt1e.appendChild(opt1etext);
drop.appendChild(opt1e);

var opt1c = document.createElement('option');
opt1c.value = "css/beer.css";
var opt1ctext = document.createTextNode('birra, giallo+bianco');
opt1c.appendChild(opt1ctext);
drop.appendChild(opt1c);

var opt1b = document.createElement('option');
opt1b.value = "css/berries.css";
var opt1btext = document.createTextNode('frutti di bosco, viola');
opt1b.appendChild(opt1btext);
drop.appendChild(opt1b);

var opt1f = document.createElement('option');
opt1f.value = "css/orange.css";
var opt1ftext = document.createTextNode('arancio, bianco, nero');
opt1f.appendChild(opt1ftext);
drop.appendChild(opt1f);

var opt2 = document.createElement('option');
opt2.value = "css/highcontrast.css";
var opt2text = document.createTextNode('forte contrasto, nero su bianco');
opt2.appendChild(opt2text);
drop.appendChild(opt2);

var opt3 = document.createElement('option');
opt3.value = "css/darkcontrast.css";
var opt3text = document.createTextNode('forte contrasto, bianco su nero');
opt3.appendChild(opt3text);
drop.appendChild(opt3);

li3.appendChild(drop);
ul.appendChild(li3);

headerdiv.insertBefore(popupdiv,firstdiv);

}

function hidepopup() {
var popup = document.getElementById("header_popup");
var div = popup.parentNode;
div.removeChild(popup);
}

function setdropcss() {
var dropselect = document.getElementById("header_popup_select");
var whichone = dropselect.options[dropselect.selectedIndex].value;
changecss('pagestyle',whichone);
}

function setdropcss2() {
var dropselect2 = document.getElementById("header_popup_select2");
var whichone2 = dropselect2.options[dropselect2.selectedIndex].value;
changecss('font',whichone2);
}

function changecss(which,css) {
var linkcss = document.getElementsByTagName("link");
var n = stylesheets[which];
var whichcss = linkcss[n];
whichcss.href = css;
setcookiecss(which,css);
js_globalstyle[which] = css; 
hidepopup();
}

function setcookiecss(which,css) {
var cookiename = which;
var date = new Date();
date.setTime(date.getTime()+(8*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
var csscookie = cookiename+"="+css;
document.cookie = csscookie+expires+"; path=/; domain=donatofurlani.it";
}
                           
