//funzioni
function plusFont() {
	if(ok) {
		var size = stile[0].style.fontSize.substring(0,2)		
		var dimFont = parseInt(size,10)		
		dimFont += 1; //incremento di 1
		{
			if (dimFont > 14) dimFont = 14;
		}
	  	stile[0].style.fontSize = dimFont + 'px';
	  	createCookie("fontsize", dimFont, 365);
	}
}

function lessFont() {
	if(ok) {
		var size = stile[0].style.fontSize.substring(0,2)
		var dimFont = parseInt(size,10)
		dimFont -= 1; //decremento di 1
		{
			if (dimFont < 10) dimFont = 10;
		}
	  	stile[0].style.fontSize = dimFont + 'px';
		createCookie("fontsize", dimFont, 365);	
	}
}

function resetFont() {
	if(ok) {
	  	stile[0].style.fontSize = 12 + 'px';
	  	createCookie("fontsize", 12, 365);	
	}
}

function directFont(dimFont) {
	if(ok) {
	  	stile[0].style.fontSize = dimFont + 'px';
	}
}

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;
}

//browser & method sniffing
ok = (document.styleSheets) ? 1 : 0;

IE = ((ind1 = navigator.appVersion.indexOf("MSIE")) > -1) ? 1 : 0;
IE4 = (IE && document.all) ? 1:0;

NN = (navigator.appName.indexOf("Netscape")>-1) ? 1 : 0;
NN4 = (NN && document.layers) ? 1 : 0;
NN6 = (NN && document.getElementById) ? 1:0;

if(ok) { //modificate per @import
  if(IE4) stile = document.styleSheets[6].imports[0].rules;
  if(NN6) stile = document.styleSheets[6].cssRules[0].styleSheet.cssRules;
}

window.onload = function(e) {
  var cookie = readCookie("fontsize");
  cookie ? directFont(cookie) : 0;
}

var cookie = readCookie("fontsize");
cookie ? directFont(cookie) : 0;