//CAMBIA IL FOGLIO DI STILE
//legge la cookie
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=/';
}

//scrive la cookie
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 setActiveStyleSheet(title) {
  var i, a, main;
  if (title) {
    for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
      if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title')) {
        a.disabled = true;
        if(a.getAttribute('title') == title) a.disabled = false;
      }
    }
  }
}

function getActiveStyleSheet() {
    var i, a;
    for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
      if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled) return a.getAttribute('title');
    }
    return null;
}


function cambia_css(size, nomecss,codice) { 
   var nome_css;
   if (size == 0) nome_css = "/Interfaccia/"+ codice + "/" + nomecss +"/" + nomecss + ".css";
   if (size == 1) nome_css = "/Interfaccia/"+ codice + "/" + nomecss +"/" + nomecss + "_big.css";
   if (size == 2) nome_css = "/Interfaccia/"+ codice + "/" + nomecss +"/" + nomecss + "_biggest.css";
   if (size == 3) nome_css = "/Interfaccia/"+ codice + "/" + nomecss +"/" + nomecss + "_alta_visibilita.css";
   alert(nome_css);
   createCookie('fontUtente',size,365);
   var link_ = document.getElementsByTagName("link");
   link_[0].href=nome_css;
} 

function set_font(nomecss) { 
  var nome_css;
  nome_css = "/Css/"+ nomecss +".css";
  size = readCookie('fontUtente');
   if (size == 0) nome_css = "/Css/"+ nomecss +".css";
   if (size == 1) nome_css = "/Css/"+ nomecss +"_big.css";
   if (size == 2) nome_css = "/Css/"+ nomecss +"_biggest.css";
   if (size == 3) nome_css = "/Css/"+ nomecss +"_alta_visibilita.css";
   var link_ = document.getElementsByTagName("link");
   link_[0].href=nome_css;
}

function RegolaDimensioneFont(azione) {
var ok, IE, NN, NN4, NN6, IE4, OP, NOT

	ok = (document.styleSheets) ? 1 : 0;
	OP = (window.opera) ? 1:0; 
	IE4 = (document.all && !OP) ? 1:0; 
	IE5 = (IE4 && document.getElementById) ? 1:0; 
	NN = (navigator.appName.indexOf("Netscape")>-1) ? 1 : 0;
	NN4 = (document.layers) ? 1:0; 
	NN6 = (!IE4 && !NN4 && document.getElementById) ? 1:0; 
	NOT = (!OP && !IE4 && !IE5 && !NN4 && !NN6) ? 1:0; 	
	
	if (!(NOT)) {
		if(IE4) stile = document.styleSheets[0].rules
		if( NN6 || NN) stile = document.styleSheets[0].cssRules
		
		var size;
		/*
		if(NN)  
			size = stile[6].style.fontSize.substring(0,2)
		else
			size = stile[0].style.fontSize.substring(0,2)

		var dimFont = parseInt(size,10)
	    if (azione=='aumenta') {
				dimFont += 10;
				if (dimFont >90) 
					dimFont =90;
			}
		else {
				dimFont -= 10;
				if (dimFont <70) 
					dimFont =75;
		}
		
		if(NN)  
			stile[6].style.fontSize = dimFont + '%';
		else	
			stile[0].style.fontSize = dimFont + '%';
		*/
		document.body.style.fontSize = dimFont + '%';
	} 
}

function DimensionaFont(Dimensione) {
var ok, IE, NN, NN4, NN6, IE4, OP, NOT

	ok = (document.styleSheets) ? 1 : 0;
	OP = (window.opera) ? 1:0; 
	IE4 = (document.all && !OP) ? 1:0; 
	IE5 = (IE4 && document.getElementById) ? 1:0; 
	NN = (navigator.appName.indexOf("Netscape")>-1) ? 1 : 0;
	NN4 = (document.layers) ? 1:0; 
	NN6 = (!IE4 && !NN4 && document.getElementById) ? 1:0; 
	NOT = (!OP && !IE4 && !IE5 && !NN4 && !NN6) ? 1:0; 	
	
	if (!(NOT)) {
	
		if(IE4) stile = document.styleSheets[0].rules
		if( NN6 || NN) stile = document.styleSheets[0].cssRules
		
		var size;
		//alert(stile[0].style);
		/*
		if(NN)  
			size = stile[6].style.fontSize.substring(0,2)
		else
			size = stile[0].style.fontSize.substring(0,2)

		if(NN)  
			stile[6].style.fontSize = Dimensione + '%';
		else	
			stile[0].style.fontSize = Dimensione + '%';
		*/
		document.body.style.fontSize = Dimensione + '%';
	} 
}




