// Decide browser version
var bV=parseInt(navigator.appVersion);
NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4)) ? true : false;
DOM=(!document.layers && !document.all && bV>=4) ? true : false; // A hack to guess if the browser supports the DOM
capable = (NS4 || IE4 || DOM) ? true : false;


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];
	var percentuale = "100%"; // 80 default
	if (size == 1) percentuale = "100%"; //70
	if (size == 2) percentuale = "120%"; //80
	if (size == 3) percentuale = "130%"; //90
	if (size == 4) percentuale = "140%"; //100
	if (size == 5) percentuale = "200%"; //110
	body.style.fontSize = percentuale;
	createCookie('rtgalleryfontsize',size,365);
}
function setFontSizeart(sizeart) {
	if (IE4) var articolo = document.all.zoomarticolo;
    if (NS4) var articolo = document.layers('zoomarticolo');
	if(DOM) var articolo = document.getElementById('zoomarticolo');
	if (articolo!= null){
	var percentuale = "100%"; // 80 default
	if (sizeart == 1) percentuale = "100%"; //70
	if (sizeart == 2) percentuale = "120%"; //80
	if (sizeart == 3) percentuale = "130%"; //90
	if (sizeart == 4) percentuale = "140%"; //100
	if (sizeart == 5) percentuale = "200%"; //110
	articolo.style.fontSize = percentuale;
	createCookie('rtgalleryfontsizeart',sizeart,365);
	}
}

function setFontSizenew(sizenew) {
	if (IE4) var news = document.all.zoomtestonew;
    if (NS4) var news = document.layers('zoomtestonew');
	if(DOM) var news = document.getElementById('zoomtestonew');
	if (news!= null){
	var percentuale = "100%"; // 80 default
	if (sizenew == 1) percentuale = "100%"; //70
	if (sizenew == 2) percentuale = "120%"; //80
	if (sizenew == 3) percentuale = "130%"; //90
	if (sizenew == 4) percentuale = "140%"; //100
	if (sizenew == 5) percentuale = "200%"; //110
	news.style.fontSize = percentuale;
	createCookie('rtgalleryfontsizenew',sizenew,365);
	}
}

function setFontSizebio(sizebio) {
	if (IE4) var bio = document.all.biografia;
    if (NS4) var bio = document.layers('biografia');
	if(DOM) var  bio = document.getElementById('biografia');
	if (bio!= null){
	var percentuale = "100%"; // 80 default
	if (sizebio == 1) percentuale = "100%"; //70
	if (sizebio == 2) percentuale = "120%"; //80
	if (sizebio == 3) percentuale = "130%"; //90
	if (sizebio == 4) percentuale = "140%"; //100
	if (sizebio == 5) percentuale = "200%"; //110
	bio.style.fontSize = percentuale;
    createCookie('rtgalleryfontsizebio',sizebio,365);

	}
}

window.onload = function() {
	size = readCookie('rtgalleryfontsize');
	setFontSize(size);
	
	sizeart = readCookie('rtgalleryfontsizeart');
	setFontSizeart(sizeart);
	
	sizenew = readCookie('rtgalleryfontsizenew');
	setFontSizenew(sizenew);
    
	sizebio = readCookie('rtgalleryfontsizebio');
	setFontSizebio(sizebio);
}

