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 styleSheet(newSize){
	setCookie("styleSheet", newSize, expires,"/");
	if (getCookie("styleSheet"))
		window.self.location.reload();
	else{
		alert("El navegador no acepta cookies. Hay que activar la opcion para poder cambiar el tamaño de letra.");
		cadena = new String(window.self.location);
		str = cadena.toString();

		if (str.indexOf("?")==-1)
			window.location=str+"?estil="+newSize;
		else
			window.location=str.substr(0,str.indexOf("?"))+"?estil="+newSize;
	}
	return null;
}


function ConsultaEstil(){
	// Comprovem que s'accepten cookies
	setCookie("Existencia", "1", expires,"/");
	if (getCookie("Existencia")){
		var fulla = getCookie('styleSheet');
		if (fulla==null || fulla == "" || fulla=="undefined"){
			fulla = "normal";
			setCookie("styleSheet", fulla, expires, "/");
		}
		return fulla;	
	}
	else{
		//si no hi ha info sobre cookies assigno 11 a pinyó
		fulla = "normal";
	}
	return fulla;
}


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);
}