	function displayImagen (foto, element) {
		document.getElementById(element).src = foto;
		var pic = foto;
	}

	function MM_swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	function MM_findObj(n, d) { //v4.01
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
		var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	function MM_reloadPage(init) {  //reloads the window if Nav4 resized
		if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
		else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
		}
		

	function moveTo(nr, orden) {
		var oForm = document.forms['aptSelectorForm'];
//		var oForm = document.forms['searchAptForm'];
		oForm.pageNum.value = nr;
		oForm.tipoOrdenacion.value = orden;
		oForm.submit();
	}

	function moveToTestimonial(nr) {
		var oForm = document.forms['testiSelectorForm'];
		oForm.pageNum.value = nr;
		oForm.submit();
	}
	
	function cambiarPrefijos(pais) {
		document.getElementById('prefijotelf').value= '+'+prefijos[pais];
		document.getElementById('prefijomovil').value= '+'+prefijos[pais];
		
	}
	
	
	
	// Controlamos si la fecha que nos están introduciendo es menor que el día actual
	function comprobarDia(yearSel, mesSel, diaSel, yearHoy, monthHoy, dayHoy, msg) {	
		var fechaHoy= yearHoy+monthHoy+dayHoy;
		var fechaSel= yearSel+mesSel+diaSel;
		
		if (fechaHoy>fechaSel) {
			alert (msg);
			return false;
		}
		return true;
	}
	
	// 
	function anadirCarro(id, reservar) {
		var oForm = document.forms['cestaAptForm'];
		oForm.anadir_carro.value = 'anadir';
		oForm.reservar.value = reservar;
		oForm.submit();
	}
	
	// 
	function eliminarCarro(id_res) {
		var oForm = document.forms['reserAptForm'];
		oForm.eliminar_reserva.value = id_res;
		oForm.submit();
	}
	
	// 
	function irMonuSearch(monu_id, nombre) {
		var oForm = document.forms['aptMonumentosForm'];
		oForm.monumento.value = monu_id;
		oForm.monu_name.value = nombre;
		oForm.submit();
	}
	
	// 
	function monuPosterior(ini, rutaweb) {
		var oForm = document.forms['aptMonumentosForm'];
		var i= oForm.primer.value;
		var tot= oForm.count.value;
		
		total= parseInt(tot);
		next_index= ini
		for (var j = 1; j <= 5; j++) {
			next_index= next_index + 1;
			if (next_index < 1) next_index= total;
			if (next_index > total) next_index= 1;
			
			//oForm.enlaceMonu[j].value= i;
			id_source = 'imgMonu' + (j);
			img = document.getElementById(id_source);
			
//			img.src = '../_fotosmonu/'+fotos[next_index];
			img.src = rutaweb+fotos[next_index];
			img.alt= nombre[next_index];
			document.getElementById('imgMonu'+(j)).alt= nombre[next_index];
			document.getElementById('imgMonu'+(j)).title= nombre[next_index];
			document.getElementById('enlaceMonu'+(j)).href= 'javascript:irMonuSearch(\''+codigo[next_index]+'\', \''+nombre[next_index]+'\')';
			document.getElementById('autorMonu'+(j)).innerHTML= autor[next_index];
		}
		ini= ini + 1;
		if (ini > total) ini= 1;
  		return ini;
	}
	// 
	function monuAnterior(ini, rutaweb) {
		var oForm = document.forms['aptMonumentosForm'];
		var i= oForm.primer.value;
		var tot= oForm.count.value;
		
		total= parseInt(tot);
		next_index= ini-2;
		for (var j = 1; j <= 5; j++) {
			next_index= next_index + 1;
			if (next_index < 1) next_index= total;
			if (next_index > total) next_index= 1;
			
			//oForm.enlaceMonu[j].value= i;
			id_source = 'imgMonu' + (j);
			img = document.getElementById(id_source);
			
//			img.src = '../_fotosmonu/'+fotos[next_index];
			img.src = rutaweb+fotos[next_index];
			img.alt= nombre[next_index];
			document.getElementById('imgMonu'+(j)).alt= nombre[next_index];
			document.getElementById('imgMonu'+(j)).title= nombre[next_index];
			document.getElementById('enlaceMonu'+(j)).href= 'javascript:irMonuSearch(\''+codigo[next_index]+'\', \''+nombre[next_index]+'\')';
			document.getElementById('autorMonu'+(j)).innerHTML= autor[next_index];
			
		}
		ini= ini - 1;
		if (ini < 1) ini= total;
  		return ini;
	}
	
	
	// 
	function testiPosterior(ini) {
		var oForm = document.forms['aptTestimoniosForm'];
		var i= oForm.primer.value;
		var tot= oForm.count.value;
		
		total= parseInt(tot);
		next_index= ini

			next_index= next_index + 1;
			if (next_index < 1) next_index= total;
			if (next_index > total) next_index= 1;
			
			document.getElementById('textTestimonio').innerHTML= '<b>"'+testimonio[next_index]+'"</b><br /><br />';
			document.getElementById('nombreTestimonio').innerHTML= autor[next_index];
			document.getElementById('paisTestimonio').innerHTML= pais[next_index];
			document.getElementById('fecTestimonio').innerHTML= fechas[next_index];

		ini= ini + 1;
		if (ini > total) ini= 1;
  		return ini;
	}
	
	// 
	function testiAnterior(ini) {
		var oForm = document.forms['aptTestimoniosForm'];
		var i= oForm.primer.value;
		var tot= oForm.count.value;
		
		total= parseInt(tot);
		next_index= ini-2;
		
			next_index= next_index + 1;
			if (next_index < 1) next_index= total;
			if (next_index > total) next_index= 1;
			
			document.getElementById('textTestimonio').innerHTML= '<b>'+testimonio[next_index]+'</b><br /><br />';
			document.getElementById('nombreTestimonio').innerHTML= autor[next_index];
			document.getElementById('paisTestimonio').innerHTML= pais[next_index];
			document.getElementById('fecTestimonio').innerHTML= fechas[next_index];
			
		
		ini= ini - 1;
		if (ini < 1) ini= total;
  		return ini;
	}
	

	
	function checkReservaForm(f, idioma) {
		ERROR = "";
		if (f.nombre.value == '' || f.nombre.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your first name.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre pr&eacute;nom.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el campo de nombre.<br/>";
					}
		}
		if (f.apellido.value == '' || f.apellido.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your last name.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre nom.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el campo de apellido.<br/>";
					}
		}
		if (f.direccion.value == '') {
			if (idioma==1) {
				ERROR += "Please enter your address.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre adresse.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene su direcci&oacute;n de residencia.<br/>";
					}
		}
		if (f.codpos.value == '') {
			if (idioma==1) {
				ERROR += "Please enter your ZIP.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre code postal.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene su c&oacute;digo postal.<br/>";
					}
		}
		if (f.poblacion.value == '') {
			if (idioma==1) {
				ERROR += "Please enter your city.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre ville.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene su ciudad.<br/>";
					}
		}
		if (f.paisresidencia.value == '') {
			if (idioma==1) {
				ERROR += "Please select a country.<br/>";
			} else if (idioma==3) {
					ERROR += "Choisissez un pays.<br/>";
				} else if (idioma==2) {
						ERROR += "Seleccione su pa&igrave;s de residencia.<br/>";
					}
		}

/*
	    if (f.prefijotelf.value == '' || f.prefijotelf.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your prefix phone.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre prefix t&eacute;l&eacute;phone.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el prefijo telefonico.<br/>";
					}
	    }
	    if (f.telf.value == '' || f.telf.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your day time phone.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre num&eacute;ro de t&eacute;l&eacute;phone.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el numero de tel&eacute;fono.<br/>";
					}
	    }
	    if (f.prefijomovil.value == '' || f.prefijomovil.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your prefix phone.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre prefix t&eacute;l&eacute;phone.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el prefijo telefonico.<br/>";
					}
	    }
	    if (f.movil.value == '' || f.movil.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your mobile phone.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre mobile t&eacute;l&eacute;phone.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el campo de tel&eacute;fono m&oacute;vil.<br/>";
					}
	    }
*/
	 
		 
	   if ((f.movil.value == '' || f.movil.value == ' ' ) && (f.telf.value == '' || f.telf.value == ' ' )) {
				if (idioma==1) {
					ERROR += "Please enter your mobile phone or your phone.<br/>";
				} else if (idioma==3) {
						ERROR += "Saisissez votre mobile t&eacute;l&eacute;phone o votre t&eacute;l&eacute;phone.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el campo de tel&eacute;fono m&oacute;vil o su tel&eacute;fono.<br/>";
				}
	   }
		
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(f.email.value))) {
			if (idioma==1) {
				ERROR += "Please enter a valid email.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez une adresse email valide.<br/>";
				} else if (idioma==2) {
						ERROR += "Escriba una direccion email v&aacute;lida.<br/>";
					}
		}
		if (f.email.value != f.reemail.value) {
			if (idioma==1) {
				ERROR += "The two mails have to be the same.<br/>";
				f.reemail.value = "";
			} else if (idioma==3) {
					ERROR += "Les deux mails doivent être identiques.<br/>";
					f.reemail.value = "";
				} else if (idioma==2) {
						ERROR += "Los dos emails deben ser iguales.<br/>";
						f.reemail.value = "";
					}
		}
		
		if (f.aceptar.checked != true) {
			if (idioma==1) {
				ERROR += "You have to agree to the terms and conditions.<br/>";
			} else if (idioma==3) {
					ERROR += "Vous devez lire et accepter les conditions g&eacute;n&eacute;rales.<br/>";
				} else if (idioma==2) {
						ERROR += "Debe leer y aceptar las condiciones generales.<br/>";
					}
		}
		
		if (ERROR == "") {
			return true;
		} else{
			ERROR= "<br /><br />"+ERROR+"<br /><br />";
			document.getElementById('errorDiv').innerHTML= ERROR;
			return false;
		}
	}

	function checkamigosForm(f, idioma) {
		ERROR = "";
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(f.emailpropio.value))) {
			if (idioma==1) {
				ERROR += "Please enter a valid email.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez une adresse email valide.<br/>";
				} else {
					ERROR += "Escriba una direccion email v&aacute;lida.<br/>";
				}
		}
		
		if (f.emailpropio.value != f.reemailpropio.value) {
			if (idioma==1) {
				ERROR += "The two mails have to be the same.<br/>";
				f.reemailpropio.value = "";
			} else if (idioma==3) {
					ERROR += "Les deux mails doivent être identiques.<br/>";
					f.reemailpropio.value = "";
				} else {
					ERROR += "Los dos emails deben ser iguales.<br/>";
					f.reemailpropio.value = "";
				}
		}
		
		if (f.email1.value!="") {
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(f.email1.value))) {
				if (idioma==1) {
					ERROR += "Please enter a valid email.<br/>";
				} else if (idioma==3) {
						ERROR += "Saisissez une adresse email valide.<br/>";
					} else {
						ERROR += "Escriba una direccion email v&aacute;lida.<br/>";
					}
			}
		}
		if (f.email2.value!="") {
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(f.email2.value))) {
				if (idioma==1) {
					ERROR += "Please enter a valid email.<br/>";
				} else if (idioma==3) {
						ERROR += "Saisissez une adresse email valide.<br/>";
					} else {
						ERROR += "Escriba una direccion email v&aacute;lida.<br/>";
					}
			}
		}
		if (f.email3.value!="") {
			if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(f.email3.value))) {
				if (idioma==1) {
					ERROR += "Please enter a valid email.<br/>";
				} else if (idioma==3) {
						ERROR += "Saisissez une adresse email valide.<br/>";
					} else {
						ERROR += "Escriba una direccion email v&aacute;lida.<br/>";
					}
			}
		}		
		
		if (ERROR == "") {
			return true;
		} else{
			ERROR= "<br />"+ERROR+"<br />";
			document.getElementById('errorDiv').innerHTML= ERROR;
			return false;
		}
	}

	
	function checkcontactoForm (f, idioma) {
		ERROR = "";
		if (f.nombre.value == '' || f.nombre.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your first name.<br/>";
			} else if (idioma==3) {
					ERROR += "Please enter your first name.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el campo de nombre.<br/>";
					}
		}
		if (f.apellido.value == '' || f.apellido.value == ' ' ) {
			if (idioma==1) {
				ERROR += "Please enter your last name.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez votre nom.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el campo de apellido.<br/>";
					}
		}
	    
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(f.email.value))) {
			if (idioma==1) {
				ERROR += "Please enter a valid email.<br/>";
			} else if (idioma==3) {
					ERROR += "Saisissez une adresse email valide.<br/>";
				} else if (idioma==2) {
						ERROR += "Escriba una direccion email v&aacute;lida.<br/>";
					}
		}
		if (f.email.value != f.reemail.value) {
			if (idioma==1) {
				ERROR += "The two mails have to be the same.<br/>";
				f.reemail.value = "";
			} else if (idioma==3) {
					ERROR += "Les deux mails doivent être identiques.<br/>";
					f.reemail.value = "";
				} else if (idioma==2) {
						ERROR += "Los dos emails deben ser iguales.<br/>";
						f.reemail.value = "";
					}
		}
		 
		if ((f.movil.value == '' || f.movil.value == ' ' ) && (f.telf.value == '' || f.telf.value == ' ' )) {
				if (idioma==1) {
					ERROR += "Please enter your mobile phone or your phone.<br/>";
				} else if (idioma==3) {
						ERROR += "Saisissez votre mobile t&eacute;l&eacute;phone o votre t&eacute;l&eacute;phone.<br/>";
				} else if (idioma==2) {
						ERROR += "Rellene el campo de tel&eacute;fono m&oacute;vil o su tel&eacute;fono.<br/>";
				}
		}
		
		if (ERROR == "") {
			return true;
		} else{
			ERROR= "<br /><br />"+ERROR+"<br /><br />";
			document.getElementById("errorDiv").innerHTML=ERROR;
			return false;
		}
	}
	
	
	
	function cambiarDiaSelect(aForm, yearmonth, cambiar) {
		// Cambiamos los dias para seleccionar (si tiene 28, 30 o 31) en el selector del dia.
		// Además, si "cambiar=0" entonces cambiamos el selector de mesañofinal por el de mesañoinicial.
		var year= yearmonth.substr(0,4);
		var month= yearmonth.substr(4,2)-1;
		var days = 32 - new Date(year, month, 32).getDate();
		var formEl = aForm.ini_dia;
		var oldLength = formEl.length;
	
		formEl.length = days;
		
		if (oldLength < days) {
			var dx = days - oldLength;
			var value = formEl.options[oldLength-1].value;
			for (var i = 0; i < dx; i++) {
				formEl.options[oldLength].value = formEl.options[oldLength].text = ++value;
				oldLength++;
			}
		}
		
		// Provocamos que cuando cambien el mes o año inicial, se cambie el mes o año final.
		if (cambiar!= '0') {
			aForm.fin_mesany.value= yearmonth;
		}
	}
		
	
	// Controlamos si la fecha que nos están introduciendo es menor que el día actual
	function comprobarDiaNew(dateSel, dateSelFin, yearHoy, monthHoy, dayHoy, msg1, msg2) {	
		var fechaHoy= yearHoy + monthHoy + dayHoy;
		var fechaSel= dateSel.substr(6, 4) + dateSel.substr(3, 2) + dateSel.substr(0, 2);
		var fechaSelFin= dateSelFin.substr(6, 4) + dateSelFin.substr(3, 2) + dateSelFin.substr(0, 2);
		
		if (fechaHoy>fechaSel) {
			alert (msg1);
			return false;
		}
		if (fechaSelFin <= fechaSel) {
//			alert ('Departure date must be greater than the arrival.');
			alert (msg2);
			return false;
		}
		return true;
	}
	
	
	function initDaySelectorNew(aForm, fecha) {
		// Provocamos que cuando cambien el mes o año inicial, se cambie el mes o año final.
		
		//Separador para la introduccion de las fechas
		var separador = "/"
		
		//Separa por dia, mes y año
		if ( fecha.indexOf( separador ) != -1 ) {
			var posi1 = 0
			var posi2 = fecha.indexOf( separador, posi1 + 1 )
			var posi3 = fecha.indexOf( separador, posi2 + 1 )
			
			diaIni = fecha.substring( posi1, posi2 )
			mesIni = fecha.substring( posi2 + 1, posi3 )
			anioIni = fecha.substring( posi3 + 1, fecha.length )
		} else {
			diaIni = 0
			mesIni = 0
			anioIni = 0   
		}
		
		fechaFin= aForm.fec_checkout.value;
		//Separa por dia, mes y año
		if ( fechaFin.indexOf( separador ) != -1 ) {
			var posi1 = 0
			var posi2 = fechaFin.indexOf( separador, posi1 + 1 )
			var posi3 = fechaFin.indexOf( separador, posi2 + 1 )
			
			diaFin = fechaFin.substring( posi1, posi2 )
			mesFin = fechaFin.substring( posi2 + 1, posi3 )
			anioFin = fechaFin.substring( posi3 + 1, fechaFin.length )
		} else {
			this.dia = 0
			this.mes = 0
			this.anio = 0   
		}
		fini= anioIni+mesIni+diaIni;
		ffin= anioFin+mesFin+diaFin;
		
		// Si la fecha inicio es superior a la fecha final,
		// asignamos a la fecha final la de inicio + 1 dia.
		if (fini >= ffin) {
			var fecha2 = fecha;
   			var fecha3 = new Date( anioIni, mesIni-1, diaIni)
   			fecha3.setTime( fecha3.getTime()+1*24*60*60*1000 )
   			
		
			var yearm= fecha3.getYear(); 
			if (yearm < 1000) yearm+=1900; 
			var monthm= fecha3.getMonth()+1; 
			if (monthm<10) monthm= "0"+monthm; 
			var daym= fecha3.getDate(); 
			if (daym<10) daym= "0"+daym; 
			aForm.fec_checkout.value= daym+"/"+monthm+"/"+yearm;
		}
	}
	
	function cambiarParam(param1, param2, change_param3) {
		if (param1.checked) var checked= '1';
		else var checked= '0';
		
		if (param2.value != checked) {
			document.aptSelectorForm.elements[change_param3.name].value = '1';
		} else 
			document.aptSelectorForm.elements[change_param3.name].value = '0';
	}

function fecha( cadena ) {

   //Separador para la introduccion de las fechas
   var separador = "/"

   //Separa por dia, mes y año
   if ( cadena.indexOf( separador ) != -1 ) {
        var posi1 = 0
        var posi2 = cadena.indexOf( separador, posi1 + 1 )
        var posi3 = cadena.indexOf( separador, posi2 + 1 )
        this.dia = cadena.substring( posi1, posi2 )
        this.mes = cadena.substring( posi2 + 1, posi3 )
        this.anio = cadena.substring( posi3 + 1, cadena.length )
   } else {
        this.dia = 0
        this.mes = 0
        this.anio = 0   
   }
}

function mapaOK () {
	document.getElementById("main_map").className= 'show';
}

function mapaKO () {
	document.getElementById("main_map").className= 'hide';
}
