// script tratto da http://www.webaccessibile.org/

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 setFontSize(size) 
{
	var body = document.getElementsByTagName('body')[0];
	
	if (body.style.fontSize=='')
	{
		body.style.fontSize = "94%"
	}
	
	if (size=='+')
	{
		body.style.fontSize = (parseInt(body.style.fontSize) + 3) + "%";
	}
	else
	{
		body.style.fontSize = (parseInt(body.style.fontSize) - 3) + "%";
	}
	
	createCookie('TuoSitoFontSize',body.style.fontSize,365);
	
	//var percentuale = "93%"; // default
	//if (size == 1) percentuale = "90%";
	//if (size == 2) percentuale = "93%";
	//if (size == 3) percentuale = "110%";
	//body.style.fontSize = percentuale;
	//createCookie('TuoSitoFontSize',size,365);
}

function setFontSizeDefault()
{
	var body = document.getElementsByTagName('body')[0];
	body.style.fontSize="92%";
	createCookie('TuoSitoFontSize',"92%",365);
}

window.onload = function() {
	size = readCookie('TuoSitoFontSize');
	setFontSize(size);
}