//cambia hoja de estilo inicial
	function setActiveStyleSheetIdioma(idioma) {
	
	   if (!idioma || idioma == "") return;		   	
	   var i, a, main;
	   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") == idioma)	a.disabled = false;		   
	     }		
	   }
 	   var oneDay = new Date() 
  	   oneDay.setDate(oneDay.getDate() + 365); // la cookie expira dins d'un any 
	   document.cookie= "IDIOMA = " + idioma + "; expires =" + oneDay + "; path=/";	   
	}



//cambia hoja de estilo y guarda una cookie IDIOMA del idioma seleccionado.
	function setActiveStyleSheet(idioma) {		   	
	   var i, a, main;
	   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") == this.id) {
				a.disabled = false;
				//grabem cookie idioma escollit
				var oneDay = new Date() 
				oneDay.setDate(oneDay.getDate() + 365); // la cookie expira dins d'un any 
				document.cookie= "IDIOMA = " + this.id + "; expires =" + oneDay + "; path=/";			
		   }
	     }
	   }
	   
	}




// lee la cookie (IDIOMA) y activa defecto 
	function leerCookieIdioma(defecto) {
		 if (defecto==null || defecto=="") defecto = "spa";
		 var nombreCookie = "IDIOMA";
		 a = document.cookie.substring(document.cookie.indexOf(nombreCookie + '=') + nombreCookie.length + 1,document.cookie.length);		
		 if (a==null || a=="" || a.length>3 ) {
			setActiveStyleSheetIdioma(defecto);
			return null;
		 }
	     if(a.indexOf(';') != -1) a = a.substring(0,a.indexOf(';'))  
		 return a; 		 
	}

