
function envia()
{
	document.login.submit();
}



function enviafiltre()
{
	document.filtre_temes.submit();
}

function enviacerca()
{
	document.cercador.submit();
}

function enviacerca2()
{
	document.cercador2.submit();
}

/* popup centrat */
function popup(url,windowname,width,height,features) { 
width=(width)?width:screen.width/2; 
height=(height)?height:screen.height/2; 
var screenX = (screen.width/2 - width/2); 
var screenY = (screen.height/2 - height/2); 
if (features) {
var features= "width=" + width + ",height=" + height + "," + features; 	
} 
else {
var features= "width=" + width + ",height=" + height +",scrollbars=yes,status=no,resizable=no"; 
}
features += ",screenX=" + screenX + ",left=" + screenX; 
features += ",screenY=" + screenY + ",top=" + screenY; 

var mywin=window.open(url, windowname, features); 
if (mywin) 
mywin.focus(); 
return mywin; 
} 

function mostra(quin) {
if (!document.getElementById) return false;	
var	d = document.getElementById(''+ quin + '');
	if (d.className == 'denone') {
	d.className = 'debloc';
	}
	else {
	d.className = 'denone';	
	}
}

function preparaMenu () {
if(!document.getElementsByTagName) return false;
if(!document.getElementById) return false;
if(!document.getElementById("menu_principal")) return false;
							
var menu_principal = document.getElementById("menu_principal");							
var imatges = menu_principal.getElementsByTagName("img");

	for(var i = 0; i < imatges.length; i++) {	
	imatges[i].onmouseover = function() {
	fesHover(this,true);
	};	

	imatges[i].onmouseout = function() {
	fesHover(this,false);
	};	
	}
}

function preparaMenuInterior () {
if(!document.getElementsByTagName) return false;
if(!document.getElementById) return false;
if(!document.getElementById("menu_principal_interior")) return false;
							
var menu_principal = document.getElementById("menu_principal_interior");							
var imatges = menu_principal.getElementsByTagName("img");

	for(var i = 0; i < imatges.length; i++) {	
	imatges[i].onmouseover = function() {
	fesHover(this,true);
	};	

	imatges[i].onmouseout = function() {
	fesHover(this,false);
	};	
	}
}

function mostraPortada (quina,protagonista) {
// comprovacions
if(!document.getElementsByTagName) return true;
if(!document.getElementById) return true;

// les imatges de les portades
var imatges_portades = new Array()
imatges_portades[0] = 'maktub_blau.jpg';
imatges_portades[1] = 'quinta_monta_blau.jpg';
imatges_portades[2] = 'once_minutos_blau.jpg';
imatges_portades[3] = 'a_orillas_blau.jpg';
imatges_portades[4] = 'el_peregrino_blau.jpg';
imatges_portades[5] = 'brida-blau.jpg';
imatges_portades[6] = 'veronica_blau.jpg';
imatges_portades[7] = 'el_alquimista_blau.jpg';

// les frases de cada títol
var frases_titols = new Array()
frases_titols[0] = 'Una brillante recopilación de las columnas diarias de Coelho';
frases_titols[1] = 'Uno de los grandes escritores de nuestro tiempo nos invita a reflexionar sobre nuestro destino';
frases_titols[2] = 'Una novela que explora la naturaleza del sexo y del amor';
frases_titols[3] = 'Toda la poesía y magia de Paulo Coelho en una historia de amor marcada por el destino';
frases_titols[4] = 'La narración de un fantástico viaje iniciático por el Camino de Santiago';
frases_titols[5] = 'Una muestra sublime de la espiritualidad de Paulo Coelho';
frases_titols[6] = 'Nueva edición escolar de Veronika decide morir';
frases_titols[7] = 'La obra que consagró a Paulo Coelho, en una edición escolar';

var porta_portades = document.getElementById("porta_portades");
var vincle_a_fitxa_portada = document.getElementById("vincle_a_fitxa_portada");
var vincle_a_fitxa = document.getElementById("vincle_a_fitxa");
var porta_descripcions = document.getElementById("porta_descripcions");

var ruta_imatge = "img/"+ imatges_portades[quina];
var vincle = "detalle-libro.php?id_libro=" + (quina+1);
var valor_text = frases_titols[quina].toUpperCase()

// assignem nous valors
porta_portades.setAttribute("src",ruta_imatge);
vincle_a_fitxa.setAttribute("href",vincle);
vincle_a_fitxa_portada.setAttribute("href",vincle);
porta_descripcions.firstChild.nodeValue = valor_text;

//esborrem la classe 'gris_3' i la canviem per 'blanc_gris_3'
var tots_els_vincles = document.getElementsByTagName("a");

for(var i = 0; i < tots_els_vincles.length; i++) {
	if (tots_els_vincles[i].className.indexOf("vinclePortada") != -1) {
	tots_els_vincles[i].className = "blanc_gris_3 senseDecoracio vinclePortada";
	}
}
protagonista.className = "gris_3 senseDecoracio vinclePortada";
return false;
}

function fesHover (quin,estaSobre) {
if(quin.className != 'triat'){
	if (estaSobre) {
	var nom_arxiu_vell = quin.getAttribute("src");
	var nom_arxiu_nou = nom_arxiu_vell.replace('normal','hover')
	quin.setAttribute("src",nom_arxiu_nou);
	}	
	else {
	var nom_arxiu_vell = quin.getAttribute("src");
	var nom_arxiu_nou = nom_arxiu_vell.replace('hover','normal')
	quin.setAttribute("src",nom_arxiu_nou);
	}
}
}


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}



function confirmaEliminar(missatge,adreca){
var m = window.confirm(missatge)
	if (m==true){
	window.location = adreca
	}
}

// funcions que carreguem a l'inici
// --------------------------------
addLoadEvent(preparaMenu);
addLoadEvent(preparaMenuInterior);

