var dom = document.getElementById ? true:false;
var ns = navigator.appName.indexOf("Netscape")!=-1 ? true:false;
var ns4 = document.layers ? true:false;
var ie4 = document.all ? true:false;
var mac = navigator.appVersion.indexOf('Mac')!=-1 ? true:false;

function init() {
	blurLinks();
}

function preload(imgObj,imgSrc) {
	eval(imgObj+" = new Image()");
	eval(imgObj+".src = '"+imgSrc+"'");
}

function changeImg(imgObj,imgSrc) {
	if (navigator.appVersion >= "3") {
		var imatge = eval(imgSrc+".src");
		document.images[imgObj].src = imatge;
	}
}

function blurLinks() {
	if (dom) {
		lnks = document.getElementsByTagName('a');
		for (i=0;i<lnks.length;i++) {
			lnks[i].onfocus = new Function("if(this.blur) this.blur()");
		}
	} else if (ie4) {
		for (var i in document.links) {
			document.links[i].onfocus = document.links[i].blur;
		}
	}
}

function canviarIdioma(l,url) {
	saveCookie('hostalgoya_l',l,360);
	window.location = url+".php?l="+l;
}

var imatge_activa = new Array("","","");

function mostrarImatges(id) {
	if (imatge_activa[id]!="") {
		document.getElementById(id+"_"+imatge_activa[id]).className = "imatge_off";
	}
	if (id==1) {
		document.getElementById("titol_imatges_1_off").style.display = "none";
		document.getElementById("titol_imatges_1_on").style.display = "inline";
		document.getElementById("titol_imatges_2_off").style.display = "inline";
		document.getElementById("titol_imatges_2_on").style.display = "none";
		document.getElementById("imatges_1").style.display = "inline";
		document.getElementById("imatges_2").style.display = "none";
	} else {
		document.getElementById("titol_imatges_1_off").style.display = "inline";
		document.getElementById("titol_imatges_1_on").style.display = "none";
		document.getElementById("titol_imatges_2_off").style.display = "none";
		document.getElementById("titol_imatges_2_on").style.display = "inline";
		document.getElementById("imatges_1").style.display = "none";
		document.getElementById("imatges_2").style.display = "inline";
	}
}

function amagarImatges(id) {
	if (imatge_activa[id]!="") {
		document.getElementById(id+"_"+imatge_activa[id]).className = "imatge_off";
	}
	document.getElementById("titol_imatges_"+id+"_off").style.display = "inline";
	document.getElementById("titol_imatges_"+id+"_on").style.display = "none";
	document.getElementById("imatges_"+id).style.display = "none";
}

function mostrarImatge(id,fitxer) {
	var so = new SWFObject("swf/imatges.swf", "flash", "527", "380", "6", "#e0dbbe");
	so.addVariable("imatge", "imatges/imatges/"+id+"/large/"+fitxer);
	so.addVariable("color_text", "ffffff");
	so.addVariable("text_1", text_imatges);
	so.addVariable("text_2", "");
	so.addParam("scale", "noscale");
	so.addParam("menu", "false");
	so.write("flashcontent");
	if (imatge_activa[id]!="") {
		document.getElementById("img_"+id+"_"+imatge_activa[id]).className = "imatge_off";
	}
	document.getElementById("img_"+id+"_"+fitxer).className = "imatge_on";
	imatge_activa[id] = fitxer;
}

function openWindow(url,nom,ww,hh,xx,yy,toolbarx,directoriesx,statusbarx,scrollbarsx,menubarx) {
	eval(nom+"=window.open('"+url+"','"+nom+"','toolbar="+toolbarx+",directories="+directoriesx+",status="+statusbarx+",scrollbars="+scrollbarsx+",menubar="+menubarx+",width="+ww+",height="+hh+",left="+xx+",top="+yy+",x="+xx+",posy="+yy+"')");
}

function canviarMesAgenda(url,mes) {
	window.location = url+mes;
}

function saveCookie(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 deleteCookie(name) {
	saveCookie(name,"",-1);
}

function bookmark(url,title) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite(url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
	}
}