var today = new Date()

var expires = new Date();
 
// fix the bug in Navigator 2.0, Macintosh
 
fixDate(expires);
expires.setTime(expires.getTime() + 365 * 24 * 60 * 60 * 1000);

function setCookie(name, value, expires, path, domain, secure) {
 
 var curCookie = name + "=" + escape(value) +
 ((expires) ? "; expires=" + expires.toGMTString() : "") +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 ((secure) ? "; secure" : "");
 document.cookie = curCookie;
}

function getCookie(name) {
 var dc = document.cookie;
 var prefix = name + "=";
 var begin = dc.indexOf("; " + prefix);
 if (begin == -1) {
 begin = dc.indexOf(prefix);
 if (begin != 0) return null;
 } else
 begin += 2;
 var end = document.cookie.indexOf(";", begin);
 if (end == -1)
 end = dc.length;
 return unescape(dc.substring(begin + prefix.length, end));
}



function FullEstil(nouTamany){
 	setCookie("FullEstil", nouTamany, expires,"/");
	if (getCookie("FullEstil"))
	{
		window.self.location.reload();
	}else{
	
		alert("Has d'activar les cookies del teu navegador per tal que el canvi de tamany de lletra sigui permanent en totes les pàgines.");
		cadena = new String(window.self.location);
		str = cadena.toString();
		if (str.indexOf("?")==-1){
			window.location=str+"?estil="+nouTamany;
		}else{
			window.location=str.substr(0,str.indexOf("?"))+"?estil="+nouTamany;
		
		}
	}
	return null;

}

function ConsultaEstil(){

	// Comprovem que s'accepten cookies
	 setCookie("Existencia", "1", expires,"/");
	
	if (getCookie("Existencia"))
	{
		var fulla = getCookie('FullEstil');
	
		if (fulla==null || fulla == "" || fulla=="undefined"){
			fulla = "tamany11";
			setCookie("FullEstil", fulla, expires, "/");
		}
	
		return fulla;	
	}
	else{
		//si no hi ha info sobre cookies assigno 11 a pinyó
		fulla = "tamany11";
	}
	return fulla;
}
if (document.images) {

	tamany_11_Off = new Image(17,16); tamany_11_Off.src = "img/mt11_0.gif";
	tamany_11_On = new Image(17,16); tamany_11_On.src = "img/mt11_1.gif";
	tamany_14_Off = new Image(17,16); tamany_14_Off.src = "img/mt14_0.gif";
	tamany_14_On = new Image(17,16); tamany_14_On.src = "img/mt14_1.gif";
	tamany_17_Off = new Image(17,16); tamany_17_Off.src = "img/mt17_0.gif";
	tamany_17_On = new Image(17,16); tamany_17_On.src = "img/mt17_1.gif";

}

function cambiar(imgName,imgObjName) {
if (document.images) {
  //document.images[imgName].src = eval(imgObjName + ".src");
  document.images[imgName].src = imgObjName;
}}

function deleteCookie(name, path, domain) {
 
 if (getCookie(name)) {
 document.cookie = name + "=" +
 ((path) ? "; path=" + path : "") +
 ((domain) ? "; domain=" + domain : "") +
 "; expires=Thu, 01-Jan-70 00:00:01 GMT";
 }
 
}


function fixDate(date) {
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)
date.setTime(date.getTime() - skew);
}
