

taronja=new Image();
taronja.src="/img/2008/fletxa_taronja2.gif";

blau=new Image();
blau.src="/img/2008/fletxa_blau2.gif";

function menu_in(num,color){
	document.getElementById("flet"+num).src="/img/2008/fletxa_"+color+"2.gif";
}

function menu_out(num,color){
	document.getElementById("flet"+num).src="/img/2008/fletxa_"+color+".gif";
}

function tancar_foto_gran(){	
	HideContent('mfoto');
	document.getElementById('foto_gran').src="/img/2008/carregant_foto_gran.gif";
}

function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	if(d.length < 1) { return; }
	if(d=="mfoto") document.getElementById(d).style.height=zxcBdyWH()[1]+'px';
	document.getElementById(d).style.display = "block";
}

function zxcBdyWH(){
	if (document.body.scrollHeight>document.body.offsetHeight) return [document.body.scrollWidth,document.body.scrollHeight]; // all but Explorer Mac
	return [document.body.offsetWidth,document.body.offsetHeight]; // Explorer Mac;
}

function ampliar_foto(nom_galeria,galeria,foto,referencia,gratuit){
	document.getElementById('ngaleria').innerHTML=nom_galeria;
	document.getElementById('ref').innerHTML="Ref: "+referencia+"<br>&nbsp;<br>&nbsp;";
	document.form_cistella.foto.value=referencia;
	document.getElementById('foto_gran').src="/img/2008/carregant_foto_gran.gif";
	document.getElementById('foto_gran').src="foto_gran.php?galeria="+galeria+"&foto="+foto;
	
	HideContent("descarregar_foto");
	HideContent("comprar_foto");
	
	if(gratuit=="0") ShowContent("comprar_foto");	
	if(gratuit=="1") ShowContent("descarregar_foto");
	
	ShowContent("mfoto");
}

function descarregar_foto(){
	f=document.form_cistella;
	galeria=f.galeria.value;
	foto=f.foto.value;
	location.href="/descarregar_foto.php?galeria="+galeria+"&foto="+foto
}

function contactar(){
	f=document.form_contactar;
	if(f.nom.value.length<2) alert("Introdueixi el seu nom");
	else if(!isValidEmail(f.email.value)) alert("Introdueixi el seu e-mail");
	else if(f.comentaris.value.length<2) alert("Introdueixi els seus comentaris");
	else {
		f.submit();
	}
}

function contactar_es(){
	f=document.form_contactar;
	if(f.nom.value.length<2) alert("Introduzca su nombre");
	else if(!isValidEmail(f.email.value)) alert("Introduzca su e-mail");
	else if(f.comentaris.value.length<2) alert("Introduzca sus comentarios");
	else {
		f.submit();
	}
}

function finalitzar_compra(){
	f=document.form_finalitzar;
	if(f.nom.value.length<2) alert("Introdueixi el seu nom");
	else if(f.dni.value.length<9) alert("Introdueixi el seu DNI o NIF");
	else if(f.direccio.value.length <2) alert("Introdueixi la seva direcció");
	else if(f.apartat_postal.value.length != 5) alert("Introdueixi el seu codi postal");
	else if(f.ciutat.value.length <2) alert("Introdueixi la seva població");
	else if(f.provincia.value.length <2) alert("Introdueixi la seva provincia");
	else if(f.telefon.value.length <2) alert("Introdueixi el seu telèfon");
	else if(!isValidEmail(f.email.value)) alert("Introdueixi el seu e-mail");
	else {
		f.submit();
	}
}

function finalitzar_compra_es(){
	f=document.form_finalitzar;
	if(f.nom.value.length<2) alert("Introduzca su nombre");
	else if(f.dni.value.length<9) alert("Introduzca su DNI o NIF");
	else if(f.direccio.value.length <2) alert("Introduzca su dirección");
	else if(f.apartat_postal.value.length != 5) alert("Introduzca su código postal");
	else if(f.ciutat.value.length <2) alert("Introduzca su población");
	else if(f.provincia.value.length <2) alert("Introduzca su provincia");
	else if(f.telefon.value.length <2) alert("Introduzca su teléfono");
	else if(!isValidEmail(f.email.value)) alert("Introduzca su e-mail");
	else {
		f.submit();
	}
}

function entrar_zona_privada(){
	f=document.form_privat;
	if(f.usuari.value.length==0) alert("Introdueixi el seu nom d'usuari");
	else if(f.pass.value.length==0) alert("Introdueixi la seva contrasenya");
	else {
		f.submit();
	}
}

function entrar_zona_privada_es(){
	f=document.form_privat;
	if(f.usuari.value.length==0) alert("Introduzca su nombre de usuario");
	else if(f.pass.value.length==0) alert("Introduzca su contraseña");
	else {
		f.submit();
	}
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}