// JavaScript Document
//emula la función trim de php, eliminando los espacios a ambos lados de la cadena
String.prototype.trim = function(){return this.replace(/^\s+|\s+$/g,'')}

function validar_telefono(telf) {
	
	if (telf!='') {
		if (/^[0-9]{2,3}-? ?[0-9]{6,7}$/.test(telf)){
			return (true);
		} else {
		 return (false);
		}
	}
	return (true);
}
function carga_accordion(){
		ddaccordion.init({
		headerclass: "silverheader",
		contentclass: "submenu",
		revealtype: "mouseover",
		collapseprev: true, 
		defaultexpanded: [], 
		onemustopen: false, 
		animatedefault: false, 
		persiststate: true, 
		toggleclass: ["", "selected"],
		togglehtml: ["", "", ""], 
		animatespeed: "fast", 
		oninit:function(headers, expandedindices){},
		onopenclose:function(header, index, state, isuseractivated){}
	})
}

function carga_accordionII(){
	ddaccordion.init({
	headerclass: "destacados",
	contentclass: "destacados_c",
	revealtype: "mouseover",
	collapseprev: true, 
	defaultexpanded: [], 
	onemustopen: false, 
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", "selected"],
	togglehtml: ["none", "", ""], 
	animatespeed: "fast", 
	oninit:function(headers, expandedindices){},
	onopenclose:function(header, index, state, isuseractivated){}
})
}
function carga_accordionIII(){
	ddaccordion.init({
	headerclass: "acc",
	contentclass: "acc_c",
	revealtype: "mouseover",
	collapseprev: true, 
	defaultexpanded: [], 
	onemustopen: false, 
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", "selected"],
	togglehtml: ["none", "", ""], 
	animatespeed: "fast", 
	oninit:function(headers, expandedindices){},
	onopenclose:function(header, index, state, isuseractivated){}
})
}
function carga_accordionV(){
	ddaccordion.init({
	headerclass: "acord",
	contentclass: "acord_c",
	revealtype: "onclick",
	collapseprev: true, 
	defaultexpanded: [], 
	onemustopen: false, 
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", "selected"],
	togglehtml: ["none", "", ""], 
	animatespeed: "medium", 
	oninit:function(headers, expandedindices){},
	onopenclose:function(header, index, state, isuseractivated){}
})
}
function carga_accordionVI(){
	ddaccordionII.init({
	headerclass: "acord",
	contentclass: "acord_c",
	revealtype: "mouseover",
	collapseprev: true, 
	defaultexpanded: [0], 
	onemustopen: true, 
	animatedefault: true, 
	persiststate: false, 
	toggleclass: ["", "selected"],
	togglehtml: ["none", "", ""], 
	animatespeed: "medium", 
	oninit:function(headers, expandedindices){},
	onopenclose:function(header, index, state, isuseractivated){}
})
}
function carga_accordionIV(){
	ddaccordionII.init({
	headerclass: "acord",
	contentclass: "acord_c",
	revealtype: "onclick",
	collapseprev: true, 
	defaultexpanded: [], 
	onemustopen: false, 
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", "selected"],
	togglehtml: ["none", "", ""], 
	animatespeed: "medium", 
	oninit:function(headers, expandedindices){},
	onopenclose:function(header, index, state, isuseractivated){}
})
}
function carga_contenido(a,b){
		
	$('libre').style.overflow = 'none';
	new Ajax.Request('contenidos.php',{
		method:"post",
		parameters:"act="+a+"&n="+b+"&qs=con",
		onSuccess:function(result){
			$('col_izq').update(result.responseText);	
		},
		onComplete:function(){
//			$$('a.tip').each(function (i){i.style.display="block";});
			$$('a.active').each(function (i) {i.removeClassName('active');});
			$(b).addClassName('active');
		}
	});
	new Ajax.Request('contenidos.php',{
		method:"post",
		parameters:"act="+a+"&n="+b+"&qs=ofe",
		onSuccess:function(result){
			$('col_der').update(result.responseText);	
		}
	});/**/
	carga_galeria(a);
}

function validaContacto(lan){
	var f = $('contacto');
	var v = new Array();
	var error = 0;
	
	v = $('departamento').value.split('_');
	if( v[0] == '3'){
		if($('email').value.trim() == ''){
			var error = 2;
		}
	}
	//(alert(error);
	//var error = 0;
	//for(i=0;i<f.elements.length;i++){
	//	if(f.elements[i].value == ''){
	//		var error = 1;	
	//	}
	//}
	
//	if(error == 0){
//		if(!validar_email($('email').value)){
//			var error = 2;
//		}
//	}
	switch(error){
		case 0:
			var nom = $('nombre').value;
			var ape = $('apellido').value;
			var em = $('email').value;
			var dep = $('departamento').value;
			var com = $('comentario').value;
			
			new Ajax.Request('save_contacto.php',{
				method:"post",
				parameters:"nombre="+nom+"&apellido="+ape+"&email="+em+"&departamento="+dep+"&comentario="+com,
				onSuccess:function(){
					if(lan == 'es'){var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Comentario enviado</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>Gracias por su tiempo.</p><p>Reciba un cordial saludo de parte del personal del Hotel Vorafira.</p><p>Deseamos verle muy pronto.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}else{var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Comment sent.</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>Thank you for your time.</p><p>Receive a warm greeting from the staff of the Hotel Vorafira.</p><p>We want to see you very soon.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}
					$('col_izq').update(msg);
				},
				onFailure:function(){
					if(lan == 'es'){var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Contacto</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>En estos momentos ha sido imposible enviar su petici&oacute;n. Pruebe a intentarlo m&aacute; tarde.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}else{var msg = 
					'<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Contact us</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>In these moments has been impossible to send your request. Try it again later.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}
				},
				onComplete:function(){
					setTimeout(window.location='index.php',4000);
				}
			});		
		break;
//		case 1:
//			if(lan == 'es'){ alert('Debe rellenar todos los campos del formulario para enviar su comentario.');	}else{ alert('You must fill all fields for send your comment.');}
//		break;
		case 2:
			alert('mensaje de email incorrecto');
			if(lan == 'es'){alert('El email introducido no es correcto.');}else{alert('Email address you has been provided is wrong.');}	
		break;
	}
}
function validar_email(mail) {
	if (mail!='') {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)){
			return (true);
		} else {
			return (false);
		}
	}
	return (true);
}
/*function load() {
	$('contenedor_galeria').update('');
	if (GBrowserIsCompatible()) {
		var map = $('contenedor_galeria');
		map.setCenter(new GLatLng(39.5041979903009, -0.4234778881072998), 17);
	}
}*/
function cambia_idioma(url){
	new Ajax.Request('cambia_idioma.php',{
		method:"post",
		onComplete:function(){
			var v = new Array();
			var v = url.split('/');
			var n = (v.length-1);
			window.location = v[n];
		}
	});
}
function contenido_instalaciones(id){
	new Ajax.Request('contenidos_instalaciones.php',{
		method:"post",
		parameters:"id="+id,
		onSuccess:function(result){
			var v = new Array();
			var v = result.responseText.split('@@@@');
			
			if(v[0] == '1'){
				$('libre').update(v[1]);
			}else{
				$('col_izq').update(v[1]);
				$('libre').update(v[2]);
			}
			carga_galeria_sub(id);
		}
	});
}
function contenido_instalaciones_sub(id){
	new Ajax.Request('contenidos_instalaciones_sub.php',{
		method:"post",
		parameters:"id="+id,
		onSuccess:function(result){
			var v = new Array();
			v = result.responseText.split('@@@');
			$('libre').update(v[2]);
			$('apoyo_cuadro').update(v[1]);
			b = v[4].split('.');
			$('cuadro').update('<span class="desde">desde</span><span class="pvp">'+b[0]+'</span><span class="decipvp">\''+b[1]+'</span><span class="europvp"></span>');
			
		}
	});
	carga_galeria_sub(id);
	/*<?
								$pvpN=explode('.',$res_of[1][3]); 
								if(strlen($pvpN[0]) > 2){
								?>
									<span class="pvp">
										<? echo $pvpN[0];?>
									</span>
									
									
								<?
								}else{
								?>
									<span class="pvp" style="font-size:55px;">
										<?  echo $pvpN[0];?>
									</span>
									<span class="decipvp">\''<?=$pvpN[1];?></span>
									<span class="europvp"></span>
								<?
								}
								?>*/
}
function contenido_instalaciones_texto(a){

	var idio=$('idio').value;
	var reser='';
	var desde='';
	if(idio=='es'){
		reser='Reservar';
		desde='Desde';
 		ico1="Teléfono";
		ico2="Aire acondicionado";
		ico3="Calefacción";
		ico4="Televisión";
		ico5="WiFi";
		ico6="Carta de almohadas";
	}else{
		reser='Bookin';	
		desde='From'
		ico1="Phone";
		ico2="Heating";
		ico3="Air condition";
		ico4="TV";
		ico5="WiFi";
		ico6="Pillow menu";
	}
	new Ajax.Request('contenidos_instalaciones_sub.php',{
		method:"post",
		parameters:"id="+a+"&c=txt",
		onSuccess:function(result){
			var v = new Array();
			var pdf='';
			var pdfII='';
			var imgs='';
			v = result.responseText.split('@@@');
			
			if(v[6]==1){imgs+='<img src="piezas/ico1.png" title="'+ico1+'" alt="Teléfono"/>';}
			if(v[7]==1){imgs+='<img src="piezas/ico2.png" title="'+ico2+'" alt="Aire acondicionado"/>';}
			if(v[8]==1){imgs+='<img src="piezas/ico3.png" title="'+ico3+'" alt="Calefacción"/>';}
			if(v[9]==1){imgs+='<img src="piezas/ico4.png" title="'+ico4+'" alt="Televisión"/>';}
			if(v[10]==1){imgs+='<img src="piezas/ico5.png" title="'+ico5+'" alt="Wifi"/>';}
			if(v[11]==1){imgs+='<img src="piezas/ico6.png" title="'+ico6+'" alt="Carta de almohadas"/>';}
			
			if(v[2]!=''){ 
				pdf='<a class="pdf" target="_blank" href="adaptax/uploads/files/'+v[2]+'"></a>';
				pdfII='<span><a target="_blank" href="adaptax/uploads/files/'+v[2]+'"><b>+info</b> '+v[12]+'</a></span>';
			}
			
			
			$('bjolibre').style.display="block";
			$('texto_central_home').style.display="none";
			$('propiedadesICO').style.display='block';
			$('libre').style.display="block";
			$('apoyo_cuadro').style.display="block";
//			$('cuadro').style.display="block";
			$('cuadro').style.display="none";
			$('apoyo_cuadro').style.width=290+'px';
			$('propiedadesICO').style.width=290+'px';
			$('propiedadesICO').update(imgs);
			$('libre').update('<span class="pa"><div class="mgn"></div>'+pdf+v[5]+'</span>');
			$('apoyo_cuadro').update('<span class="tit">'+v[1]+'</span><span>'+v[3]+'</span>');
			b = v[4].split('.');
			if(b[0].length > 2){
						$('cuadro').update('<span class="desde">desde</span><span class="pvp">'+b[0]+'</span><span class="decipvp"style="margin:5px 0 0 5px; font-size:20px;">\''+b[1]+'</span><span class="europvp"></span>');
			}else{
						$('cuadro').update('<span class="desde">desde</span><span class="pvp" style="font-size:55px;">'+b[0]+'</span><span class="decipvp" style="margin-top:5px;">\''+b[1]+'</span><span class="europvp"></span>');
			}
			$('bjolibre').update(pdf+pdfII);
	
		}	
	});	
}
function contenido_instalaciones_textoII(a){/*En caso de que la subsección no tenga contenidos muestra los que tenga asignados ella misma "ss"*/
	
	new Ajax.Request('contenidos_instalaciones_subII.php',{
		method:"post",
		parameters:"id="+a+"&c=txt",
		onSuccess:function(result){
			var pdf='';
			var sipdf='';
			var v = new Array();
			v = result.responseText.split('@@@');
			if(v[2]!=''){pdf='<a class="rese" href="javascript:void(0)"><span class="reseA" >'+reser+'</span></a>';sipdf='libreII';}
			var inff='<span class="titular">'+v[1]+pdf+'</span><p>'+v[5]+'</p>'+'<div id="'+sipdf+'"><p>'+v[3]+'</p>'+pdf+'</div>';
			$('contenedor_texto_central').update(inff);
			$('cuadro').style.display='none';
			$('apoyo_cuadro').style.display='none';
			$('libre').style.display='none';
			carga_galeria_sub(v[0]);

		}	
	});	
	
}
function carga_galeria_sub(a){
	new Ajax.Request('galerias_sub.php',{
		method:"post",
		parameters:"act="+a,
		onSuccess:function(result){
			$('contenedor_galeria').update(result.responseText);	
			new Crossfade('fade-example-2');
			new Lightbox();
		}
	});	
}
function crea_registro(){
	if(!$('registro')){
		new Ajax.Request('formReg.php',{
			method:"post",
			onSuccess:function(result){	
				$('col_izq').update(result.responseText);
			}
		});	
	}
}
function validar_registro(lan){
	var a = $('nombre').value;
	var b = $('apellidos').value;
	var c = $('dni_cif').value;
	var d = $('localidad').value;
	var e = $('provincia').value;
	var f = $('cp').value;
	var g = $('email').value;
	var h = $('telefono').value;
	var i = $('usuario').value;
	var j = $('clave').value;
	var error = 0;
	
	if(a == '' || b == '' || c == '' || d == '' || f == '' || g == '' || h == '' || i == '' || j == ''){
		error = 1;
	}
	if(error == 0){
		if(!validar_email(g)){
			error = 2;	
		}
	}
	if(error == 0){
		if(!validar_telefono(h)){
			error = 3;	
		}
	}
	
	switch(error){
		case 0:
			$('registro').request({
				method:"post",
				onSuccess:function(result){
					switch(result.responseText){
						case '0':
							if(lan == 'es'){var msg='<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Registro de usuarios</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>El nombre de usuario ingresado ya existe. Por favor introduzca un nuevo nombre de usuario.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}else{var msg='<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">User registration</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>User name provided already exist. Please insert a new user name.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}
							$('col_izq').update(msg)
						break;
						case '1':
							if(lan == 'es'){var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Registro de usuarios</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>La clave introducida no es una clave válida. La clave debe contener al menos 6 caracteres.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}else{var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">User registration</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>The password you have provided isn&acute;t correct. Password must have at least 6 characters.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}
							$('col_izq').update(msg)
						break;
						case '2':
							if(lan == 'es'){var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Registro de usuarios</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>El email introducido ya se encuentra registrado. Introduzca otra dirección de email o puede recordar sus datos de acceso si as&iacute; lo desea.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}else{var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">User registration</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>Email address you have provided already exist. Insert a new email address or can remember your information login.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}
							$('col_izq').update(msg)
						break;
						default:
							if(lan == 'es'){var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">Registro de usuarios</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>Su registro se ha completado con éxito. Puede ingresar como usuario desde el área de clientes.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}else{var msg = '<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">User registration</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>Your registration has been successfully. You can login like user from Customer&acute;s area.</p></div></li><li id="aquiVaElPie"></li></ul></div></div>';}
							$('col_izq').update(msg)
					}
				}
			});
		break;
		case 1:
			if(lan == 'es'){alert('Debe rellenar los campos obligatorios antes de poder enviar el formulario.');}else{alert('You must fill obligatory fileds before you can submit the form.');}
			
		break;
		case 2:
			if(lan == 'es'){alert('El email introducido no es correcto, Introduzca una dirección de email válida.');}else{alert('Email address you have entered isn&acute;t correct. Please insert a valid email address.');}
		break;
		case 3:
			if(lan == 'es'){alert('El teléfono introducido no es correcto. Por favor, introduzca un número de teléfono válido.');}else{alert('Telephone you have entered isn&acute;t correct. Please, insert a valid telephone number.');}
		break;
	}
}
function gmaps1(op,str) {
	//$('contnienteContenido').update('');
	$('col_izq').update('<div class="texto_din"><ul style="float: left; list-style-image: none; list-style-position: outside; list-style-type: none; padding-left: 10px; width: 490px;"><li id="aquiVaElCab"><label id="titContGlo"></label></li><li id="aquiVaElContenido"><div id="contnienteContenido"></div></li><li id="aquiVaElPie"></li></ul></div>');
	
	if (GBrowserIsCompatible()) {
		$('contenedor_galeria').update('');
		var div = document.createElement('div');
		div.id = 'map';
		div.style.height = '265px';
		div.style.width = '460px';
		div.style.margin = '0 0 0 8px';
		$('contenedor_galeria').appendChild(div);
		//var latitud = $('latitud_hd').value;
		//var longitud = $('longitud_hd').value;
		var mapa = new GMap2(document.getElementById("map"));
		//mapa.setCenter(new GLatLng(latitud,longitud), 17);
		mapa.addControl(new GLargeMapControl());
		mapa.addControl(new GScaleControl());
		//var point = new GLatLng(latitud,longitud);
		//map.addOverlay(new GMarker(point));
		var panel = $('contnienteContenido');
/*		panel.style.width = '410px';*/
		//map.panTo(39.47074628390014, -0.37680745124816895)
		//var pixel = "39.47074628390014, -0.37680745124816895";
//		map.fromContainerPixelToLatLng(39.47074628390014, -0.37680745124816895)
		ruta = new GDirections(mapa,panel);
		var v = new Array();
		v = str.split('@@@@');
		$('mapa_actual').value = op;
		var matriz_rutas = new Array();
		
		for(i=0;i<(v.length-1);i++){
			if(v[i] !=''){
				matriz_rutas.push(v[i]);	
			}
		}
		//ruta.load("from :"+VARIABLE FROM+" to: "+VARIABLE TO,{locale: +IDIOMA});
		ruta.loadFromWaypoints(matriz_rutas,{locale: v[3]});
	}
}

function gmaps0(str) {
	
	if (GBrowserIsCompatible()) {
		if(str){
			$('mapa_actual').value = '0';
			var c = $('col_izq');					
			
			new Ajax.Request('contenidos.php',{
				method:"post",
				parameters:"qs=con&act=6",
				onSuccess:function(result){
					c.update(result.responseText);
				}
			});
		}	
		if(!$('map')){
			var div = document.createElement('div');
			div.id = 'map';
			div.style.height = '265px';
			div.style.width = '460px';
			div.style.margin = '0 0 0 8px';
			$('contenedor_galeria').appendChild(div);
		}
		var latitud = $('latitud_hd').value;
		var longitud = $('longitud_hd').value;
		
		/*mostramos una ubicación en google maps en base a las coordenadas recogidas*/
		var mapa = new GMap2(document.getElementById("map"));
		mapa.setCenter(new GLatLng(latitud,longitud), 17);
		mapa.addControl(new GLargeMapControl());
		mapa.addControl(new GScaleControl());
		
		/*definimos el icono personalizado que aparecerá en google maps*/
		var point = new GLatLng(latitud,longitud);
		//mapa.addOverlay(new GMarker(point));
		var icon = new GIcon(); 		
		icon.image = "img/interfaz/marca.png"; 
		var tam = new GSize(16,16);
		icon.iconSize = tam; 
		icon.iconAnchor = new GPoint(0,1); 
		//var marker = new GMarker(point, icon);
		var html ="<div class='infowindow'>" + "<b>Hotel Vorafira <\/b>" + "<p>Coordenadas GPS:</p><p> Latitud:"+latitud+"</p><p> Longitud:"+longitud+"</p><\/div>";	
		mapa.addOverlay(new GMarker(point,icon));
		mapa.openInfoWindow(mapa.getCenter(),html);
		
		
		
         
		  
		
		lista_ubicacion();
		//$('apoyo_cuadro').update('<span class="titLibre">En Valencia muy cerca de ti.</span>Estamos en la calle Cullera n&uacute;mero 67, frente a Feria de Valencia.');
	}
}
function gmaps(op,str){
	if(op == '0'){
		//alert(str);
		gmaps0(str);
	}else{
		//alert(str);
		gmaps1(op,str);
	}
	
}
function lista_ubicacion(){
	new Ajax.Request('listado_ubicacion.php',{
		method:"post",
		onSuccess:function(result){
			$('contenedor_texto_central_ubi').update(result.responseText);
		}
	});	
}
function carga_evento(){
	if(!$('evento')){
		var a = $('callcenter');
		var inp = document.createElement('input');
		inp.id = 'evento';
		inp.type = 'hidden';
		a.appendChild(inp);
	}
	
	new Ajax.Request('eventos.php',{
		method:"post",
		onSuccess:function(result){
			
			if(result.responseText != ''){
				var v = new Array();
				var v = result.responseText.split('==');
				
				//v[0] = ids      v[1] = cadena con mensaje
				var v_id = v[0].split('@@@@');
				var v_str = v[1].split('@@@@');
				
				if(v_id.length > 1){
					alert('vector');
				}else{
					$('area_msg').update('<label>'+v_str[0]+'</label>');		
					$('evento').value = v_id[0];
				}
			}
		}
	});
}
function reservar(lan){
	var f = $('form_reservas');	
	var a = $('num_adultos').value;
	
	var b = $('ARR').value;
	var c = $('DEP').value;
	var d = $('NOROOMS').value;
	var e = $('num_ninos_2B').value;
	var e1 = $('num_ninos_2A').value
	if(b == 'dd/mm/aaaa' || b == 'yyyy/mm/dd' || c == 'dd/mm/aaaa' || c == 'yyyy/mm/dd' || a == '' || d == ''){
		if(lan == 'es'){
			alert('Debe rellenar los campos de Fecha de entrada, Fecha de salida, número de habitaciones y Adultos antes de poder realizar una reserva.');
		}else{
			alert('You must fill in the fields of date of entry, departure date, number of rooms and adults before they can make a reservation.');
		}
	}else{
		
		if(lan == 'es'){
			var v = new Array();
			var v = b.split('/');
			
			$('ARR').value = v[2]+"-"+v[1]+"-"+v[0];
			
			var v = new Array();
			var v = c.split('/');
			
			$('DEP').value = v[2]+"-"+v[1]+"-"+v[0];
		}
	
		var n = '1A,'+a+"|2B,"+e+"|2A,"+e1;
		$('NOPAXPERGT').value = n;
		
		f.submit();
	}	
}

function reservar_juice(lan){
	var f = $('form_reservas');
	var a = $('num_adultos').value;

	var b = $('ARR').value;
	var c = $('DEP').value;
	//var d = $('NOROOMS').value;
	var e = $('num_ninos_2B').value;
	//var e1 = $('num_ninos_2A').value
	if(b == 'dd/mm/aaaa' || b == 'yyyy/mm/dd' || c == 'dd/mm/aaaa' || c == 'yyyy/mm/dd' || a == ''){
		if(lan == 'es'){
			alert('Debe rellenar los campos de Fecha de entrada, Fecha de salida y Adultos antes de poder realizar una reserva.');
		}else{
			alert('You must fill in the fields of date of entry, departure date and adults before they can make a reservation.');
		}
	}else{

		
			var varr = new Array();
			varr = b.split('/');

			//$('ARR').value = v[2]+""+v[1]+""+v[0];

			var vdep = new Array();
			vdep = c.split('/');

			//$('DEP').value = v[2]+""+v[1]+""+v[0];
		

		//var n = '1A,'+a+"|2B,"+e+"|2A,"+e1;
		//$('NOPAXPERGT').value = n;
                
                $("inidate").value = varr[2]+""+varr[1]+""+varr[0];
                $("enddate").value = vdep[2]+""+vdep[1]+""+vdep[0];
                $("pax").value = $("num_adultos").value;
                $("childs").value = $("num_ninos_2B").value;

		f.submit();
	}
}

function muestra_calendario(obj){
	var a = obj.id;
	
	if($('calendario').style.display == 'none' || $('calendario').style.display == ''){
		$('calendario').style.display  = 'block';
		$('acept').style.display = 'block';
		$('close').style.display = 'block';
	}else{
		$('calendario').style.display  = 'none';
		$('acept').style.display = 'none';
		$('close').style.display = 'none';
	}
	
	mDCal.draw();
}
function desdeCualquiera(lan,l){
	if(lan == 'es'){
		var label = 'Escriba el lugar desde donde desee llegar';
		var sm = 'Ejemplo: Calle+Cullera,+46035,+Valencia,+España';
		var btn = 'Ir';
	}else{
		var label = 'Enter the place from where you want to reach';
		var sm = 'Example: Calle+Cullera, +46035, +Valencia, +Spain';
		var btn = 'Go';
	}
	$('col_izq').update('<label for="desdeper">'+label+'&nbsp;</label><input type="text" name="desdeper" id="desdeper" size="70" /><small>'+sm+'</small><br /><div id="btn_ubi" onclick="goToLocation(\''+l+'\');">'+btn+'</div>');	
}
function goToLocation(lan){
	var a = $('desdeper').value;	
	var str = a+'@@@@Calle+Cullera,+46035,+Valencia,+España@@@@'+lan;
	gmaps(1,str);
}
function vaciaInput(obj){
	var a = obj.id;
	
	if($(a).value == 'Calle+Cullera,+46035,+Valencia,+España' || $(a).value == 'Calle+Cullera,+46035,+Valencia,+España'){
		$(a).value = '';	
	}
}
function checkInput(obj,lan){
	var a = obj.id;
	if($(a).value == ''){
		if(lan == 'es'){
			$(a).value = 'Calle+Cullera,+46035,+Valencia,+España';
		}else{
			$(a).value = 'Calle+Cullera,+46035,+Valencia,+España';
		}
	}
}
function getMap(){
	var a = $('mapa_actual').value;
	
	/*new Ajax.Request('downloadMap.php',{
		method:"post",
		parameters:"a="+a,
		onComplete:function(result){*/
			window.open('downloadMap.php?a='+a);
		/*}
	});*/
}
function validaRec(lan){
	a = $('email').value;
	var error = 0;
	
	if(a == ''){
		error = 1;	
	}
	
	if(error == 0){
		if(!validar_email(a)){
			error = 2;	
		}
	}
	
	switch(error){
		case 0:
			$('recpass').request({
				method:"post",
				onSuccess:function(result){
					if(lan == 'es'){
						var str = 'Recordar datos.';
						var str2 = 'Su solicitud se ha enviado con &eacute;xito. En breve recibir&aacute; un correo con los datos solicitados a la direcci&oacute;n que nos ha especificado.';
						var str3 = 'El correo que ha introducido no se encuentra registrado en nuestra base de datos. Por favor cerciorese de que el correo introducido se corresponde con el que nos facilit&oacute; para darse de alta como cliente. Si por el contrario no se encuentra registrado, no pierda la oportunidad y registrese desde nuestro formulario.';
					}else{
						var str = 'Recall data.';
						var str2 = 'His request has been sent successfully. You will receive an email with the requested data to the address you specified.';
						var str3 = 'The mail you´ve entered is not registered in our database. Please make sure the mail introduced corresponds to you provided for customer registration. If on the contrary are not registered, do not miss the opportunity to register in our form.';
					}
					if(result.responseText != 1){
						$('col_izq').update('<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">'+str+'</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>'+str2+'</p></div></li><li id="aquiVaElPie"></li></ul></div></div>');
					}else{
						$('col_izq').update('<div class="texto_din"><ul style="list-style-type: none; list-style-image: none; list-style-position: outside; padding-left: 10px;"><li id="aquiVaElCab"><label id="titContGlo">'+str+'</label></li><li id="aquiVaElContenido"><div id="contnienteContenido"><p>'+str3+'</p></div></li><li id="aquiVaElPie"></li></ul></div></div>');
					}
				}
			});
		break;
		case 1:
			if(lan == 'es'){
				alert('El campo del email no puede estar vacio. Por favor rellene el campo con sus datos.');
			}else{
				alert('The email field can not be empty. Please fill the field with your data.');
			}
		break;
		case 2:
			if(lan == 'es'){
				alert('El email introducido no es correcto. Por favor, introduzca una dirección de email válida.');
			}else{
				alert('The email you have entered isn´t it correct. Please enter a valid email address.');
			}
		break;
		default:
			alert('Ha ocurrido un problema durante el envío del formulario. Por favor intentelo de nuevo más tarde y disculpe las molestias.');
	}
}
function ver_galeria(obj,sec){
	var a = obj.id;
	var v = new Array();
	v = a.split('_');
	
	var b = $('contenedor_galeria');
	
	new Ajax.Request('galeria_btn.php',{
		method:"post",
		parameters:"a="+v[1]+"&g="+sec,
		onSuccess:function(result){
			b.update(result.responseText);
		},
		onComplete:function(){
			new Crossfade('fade-example-2');
			new Lightbox();	
		}
	});
}
function addComment(obj){
	var v = obj.value;
	var vector = new Array();
	vector = v.split('_');
	var a = v[0];
	
	if(a == '3'){
		$('comentario').update('Le recordamos que para obtener respuesta debe indicarnos su email en el formulario de contacto.');	
	}else{
		$('comentario').update('');
	}
}	
