chkza="small";
getCookie("fontSize");

function setCookie(name, value) {
	dataScadenza = new Date();
	//alert("qui"+dataScadenza);
	dataScadenza.setMonth(dataScadenza.getMonth() + 2);
	//alert("qui1"+dataScadenza);
	var domain="";
	//alert("qui2"+domain);
	var temp=location.hostname;
	//alert("qui3"+temp);
	domain=temp;
	//alert("qui4");
	var curCookie = name + "=" + escape(value)+ "; expires=" + dataScadenza.toGMTString() + "; path=/; domain="+domain+";";
	//alert("qui5"+curCookie);
	document.cookie = curCookie;
	//alert("qui6"+document.cookie);
	location.reload(true);
}

function getCookie(Name) {
	var search = Name + "=";
	if (document.cookie.length > 0) {
		// if there are any cookies
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			// if cookie exists
			offset += search.length;
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1) {
				end = document.cookie.length;
			}
			chkza=unescape(document.cookie.substring(offset, end));
		}
	}
}

if(chkza == "big") {
	document.write("<style>* {font-size:1.05em}</style>");
} else if(chkza == "medium") {
	document.write("<style>* {font-size:1.02em}</style>");
}

function setImageFontSize() {
	if(chkza != "") {
		var imgName = document.getElementById('font'+chkza+'Img').src.split('.gif');
		document.getElementById('font'+chkza+'Img').src = imgName[0]+'_on.gif';
	} else {
		var imgName = document.getElementById('fontsmallImg').src.split('.gif');
		document.getElementById('fontsmallImg').src = imgName[0]+'_on.gif';
	}
}

function open_primoPiano() {
	sealWin = window.open("primo_piano_popup.html","win","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=560,height=445");
}

function openClose(a) {
	//cambio immagine
	if(a.parentNode.className == 'open') {
		a.parentNode.className = 'close';
		var ps = a.parentNode.getElementsByTagName('div');
		ps[0].style.display = 'none';
	} else {
		a.parentNode.className = 'open';
		var ps = a.parentNode.getElementsByTagName('div');
		ps[0].style.display = 'block';
	}
}

function openCloseStory(a) {
	//cambio immagine
	if(a.parentNode.parentNode.className == 'open') {
		a.parentNode.parentNode.className = 'close';
		b = a.parentNode.parentNode;
		var aabb = b.getElementsByTagName('div');
		aabb[2].style.display = 'none';
	} else {
		a.parentNode.parentNode.className = 'open';
		b = a.parentNode.parentNode;
		var aabb = b.getElementsByTagName('div');
		aabb[2].style.display = 'block';
	}
}

function openCloseApriConto(a) {
	if(a.parentNode.className == 'titBoxStep_on') {
		a.parentNode.className = 'titBoxStep';
		b = a.parentNode.parentNode;
		var aabb = b.getElementsByTagName('div');
		aabb[0].style.display = 'none';
	} else {
		a.parentNode.className = 'titBoxStep_on';
		b = a.parentNode.parentNode;
		var aabb = b.getElementsByTagName('div');
		aabb[0].style.display = 'block';
	}
}


function openCloseApriContoPOS() {
    var obj=document.getElementById("title03");

    if(obj.className == 'titBoxStep_on') {
		obj.parentNode.className = 'titBoxStep';
		b = obj.parentNode.parentNode;
		var aabb = b.getElementsByTagName('div');
		aabb[0].style.display = 'none';
	} else {
		obj.className = 'titBoxStep_on';
		b = obj.parentNode;
		var aabb = b.getElementsByTagName('div');
		aabb[0].style.display = 'block';
	}
}



function swapIn(r) {
	if (r == 'play01') {
		document.getElementById('play01').style.display = 'block';
		document.getElementById('title01').className = 'titBoxStep_on';
	} else if (r == 'play02') {
		document.getElementById('play02').style.display = 'block';
		document.getElementById('title02').className = 'titBoxStep_on';
	} else if (r == 'play03') {
		document.getElementById('play03').style.display = 'block';
		document.getElementById('title03').className = 'titBoxStep_on';
	} else if (r == 'play04') {
		document.getElementById('play04').style.display = 'block';
		document.getElementById('title04').className = 'titBoxStep_on';
	} else if (r == 'play05') {
		document.getElementById('play05').style.display = 'block';
		document.getElementById('title05').className = 'titBoxStep_on';
	}
}

function apriChiudiDiv(d,t) {
	if(document.getElementById(d).style.display=='block') {
		document.getElementById(d).style.display='none';

			if(t.firstChild.src.indexOf("_up.gif")!= -1){
				img = t.firstChild.src.split("_up.gif");
			}
			else if(t.firstChild.src.indexOf("_up_on.gif")!= -1){
				img = t.firstChild.src.split("_up_on.gif");
			}
			else if(t.firstChild.src.indexOf("_on.gif")!= -1){
				img = t.firstChild.src.split("_on.gif");
			}
			else{
				img = t.firstChild.src.split(".gif");
			}

		t.firstChild.src=img[0]+"_on.gif";
	} else {
		document.getElementById(d).style.display='block';

			if(t.firstChild.src.indexOf("_up.gif")!= -1){
				img = t.firstChild.src.split("_up.gif");
			}
			else if(t.firstChild.src.indexOf("_up_on.gif")!= -1){
				img = t.firstChild.src.split("_up_on.gif");
			}
			else if(t.firstChild.src.indexOf("_on.gif")!= -1){
				img = t.firstChild.src.split("_on.gif");
			}
			else{
				img = t.firstChild.src.split(".gif");
			}

		t.firstChild.src=img[0]+"_up_on.gif";
	}
}

function changeImage(element,typeName,action) {
	if(typeName == 'firstLevel'){
		if(action=='over'){
			if(element.src.indexOf("_on.gif")!= -1){
				img = element.src.split("_on.gif");
			}
			else{
				img = element.src.split(".gif");
			}

				element.src=img[0]+"_on.gif";

		}
		else{

			if(element.src.indexOf("_on.gif")!= -1){
				img = element.src.split("_on.gif");
			}
			else{
				img = element.src.split(".gif");
			}


			element.src=img[0]+".gif";
		}
	}
	else{
		getCookie('fontSize');

		if(action=='over' && (chkza != typeName)){
			img = element.src.split(".gif");
			element.src=img[0]+"_on.gif";
		}
		else if(chkza != typeName){
			img = element.src.split("_on.gif");
			element.src=img[0]+".gif";
		}
		else if(chkza == typeName){
			img = element.src.split("_on.gif");
			element.src=img[0]+"_on.gif";
		}
	}
}


function closePopup(){
	window.close();
}

function openPopup(url,id,width,height,resizable){
	if(resizable=='no') newwindow=window.open(url,id,'height='+height+',width='+width+', scrollbars=yes');
	else newwindow=window.open(url,id,'height='+height+',width='+width+', resizable=yes, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}

function addToBookmarks(){
	var ua=navigator.userAgent;
	if (window.opera){
		//Opera 6+
		document.getElementById("bm_OP").style.display="inline";
	}else if (document.all && ua.indexOf("Mac")==-1){
		//Internet Explorer 5+
		if(document.getElementById) document.getElementById("bm_IE").style.display="inline";
		else document.all.bm_DISABLED.style.display="inline";
	}else if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")){
		//Netscape 6+, Mozilla, Firefox, (Gecko)
		document.getElementById("bm_MZ").style.display="inline";
	}else if( ua.indexOf("Mac")!=-1 && (document.all || ua.indexOf("Safari")!=-1) ){
		//Internet Explorer MAC, Safari, altri
		document.getElementById("bm_DISABLED").style.display="inline";
	}
}
function disabledBookmarks(){
	var ua=navigator.userAgent;
	if(document.all)alert("Per aggiungere questa pagina ai preferiti usa [APPLE] + [D]")
	else if (ua.indexOf("Safari")!=-1)alert("Per aggiungere questa pagina ai preferiti usa [APPLE] + [D]\noppure trascina il link sulla barra dei preferiti")
	else alert("Il browser consente questa funzione.\nUsa il menu del browser.")
}
