var txt;
function ajax(){
var xmlhttp=false;
	try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		//alert("Estas usando el I.E. 5 o superior");
	} catch (e){
		try {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			//alert("Estas usando el I.E.");
		} catch (E){
			xmlhttp=false;
		}
	}
	if(!xmlhttp&&typeof XMLHttpRquest!=undefined){
		xmlhttp=new XMLHttpRequest();
		//alert("Estas usando Firefox o Mozilla");
	}
	return xmlhttp;
}
function abrecalendario(id) {
		/*var hoy=new Date();
		var mes=hoy.getMonth()+1;
		var anho=hoy.getFullYear();*/
		var vent=window.open("calen_js.php?id="+id,"ABRE",'width= 220, height=215, resizable=0, scrollbars=0, menubar=no, status=no, top=60, left=150');
		vent.window.focus();
}
function diasemana(d,m,a){
	m--;
	if(!esfecha(d,m,a)){
		alert("Fecha imposible... Corríjala");	
		return "Error de fecha";	
	}
	m++;
	d=String(d);
	if(d.substr(0,1)=="0"){
		d=d.substr(1,1);
	}
	m=String(m);
	if(m.substr(0,1)=="0"){
		m=m.substr(1,1);
	}
	a=parseInt(a);
	m=parseInt(m)-1;
	d=parseInt(d);
	fec=new Date(a,m,d);
	
	sem=fec.getDay();
	switch (sem){
		case 0:
			semana="Domingo";
			break;
		case 1:
			semana="Lunes";
			break;
		case 2:
			semana="Martes";
			break;
		case 3:
			semana="Miercoles";
			break;
		case 4:
			semana="Jueves";
			break;
		case 5:
			semana="Viernes";
			break;
		case 6:
			semana="Sabado";
			break;
	}
	return semana;
	
}
function axcalendario(dia,mes,anho,id){
	semana=diasemana(dia,mes+1,anho);
	mes=mes+1;
	//var origen=window.opener.document.getElementById(id);
	dia=String(dia);
	if(dia.length==1){
		dia="0"+dia;	
	}
	mes=String(mes);
	if(mes.length==1){
		mes="0"+mes;	
	}
	anho=String(anho);
	if(id=="fechain"){
		window.opener.document.getElementById('diain').value=dia;
		window.opener.document.getElementById('mesin').value=mes;
		window.opener.document.getElementById('anoin').value=anho;
		window.opener.document.getElementById('semanain').innerHTML=semana;
		window.opener.document.getElementById('horain').focus();
	}
	if(id=="fechaout"){
		window.opener.document.getElementById('diaout').value=dia;
		window.opener.document.getElementById('mesout').value=mes;
		window.opener.document.getElementById('anoout').value=anho;
		window.opener.document.getElementById('semanaout').innerHTML=semana;
		window.opener.document.getElementById('horaout').focus();
	}
	window.close();
	
}
function cambiollegada(k){
	if(k=="dia"){
		document.getElementById('diaout').value=document.getElementById('diain').value;
	}
	if(k=="mes"){
		document.getElementById('mesout').value=document.getElementById('mesin').value;
	}
	if(k=="ano"){
		document.getElementById('anoout').value=document.getElementById('anoin').value;
	}
	if(k=="hora"){
		document.getElementById('horaout').value=document.getElementById('horain').value;
	}
	//valinicial();
}
function horainicial(){
	fecha=new Date();	
	dia=fecha.getDate();
	mes=fecha.getMonth()+1;
	ano=fecha.getFullYear();
	sem=diasemana(dia,mes,ano);
	dia=String(dia);
	if(dia.length==1){
		dia="0"+dia;	
	}
	mes=fecha.getMonth()+1;
	mes=String(mes);
	if(mes.length==1){
		mes="0"+mes;	
	}
	hora=fecha.getHours();
	minu=fecha.getMinutes();
	if(minu>=30){
		hora++;
		if(hora==24){
			hora=23;	
		}
		hora=String(hora);
		if(hora.length==1){
			hora="0"+hora;
		}
		hora=hora+":00";
	}else{
		hora=String(hora);
		if(hora.length==1){
			hora="0"+hora;
		}
		hora=hora+":30";
	}
	if(document.getElementById('diain')){
		document.getElementById('diain').value=dia;
		document.getElementById('mesin').value=mes;
		document.getElementById('horain').value=hora;
		document.getElementById('anoin').value=ano;
		if(document.getElementById('semanain')){
			document.getElementById('semanain').innerHTML=sem;
		}
		document.getElementById('diaout').value=dia;
		document.getElementById('mesout').value=mes;
		document.getElementById('horaout').value=hora;
		document.getElementById('anoout').value=ano;
		if(document.getElementById('semanaout')){
			document.getElementById('semanaout').innerHTML=sem;
		}
	}
}
function bisiesto(year){
	if ((year % 4 == 0) && (( year % 100 != 0) || (year % 400 ==0))){
  		return true;
	}else{
  		return false;
	}
}
function esfecha(diaf,mesf,anyo){
	
	if(bisiesto(anyo)){
		if(mesf==1 && diaf>29){
			return false;
		}
	}else{
		if(mesf==1 && diaf>28){
			return false;
		}	
	}
	if(mesf==3 || mesf==5 || mesf==8 || mesf==10){
		if(diaf>30){
			return false;	
		}	
	}
	return true;
}

function valinicial(){
	ahora=new Date();
	dia1=document.getElementById('diain').value;
	mes1=document.getElementById('mesin').value-1;
	ano1=document.getElementById('anoin').value;
	horamin1=document.getElementById('horain').value;
	hora1=horamin1.substr(0,2);
	min1=horamin1.substr(3,2);
	fecha1=new Date(ano1,mes1,dia1,hora1,min1);
	if(!esfecha(dia1,mes1,ano1)){
		alert("Fecha de Llegada incorrecta");
		return false;
	}
	
	dia2=document.getElementById('diaout').value;
	mes2=document.getElementById('mesout').value-1;
	ano2=document.getElementById('anoout').value;
	horamin2=document.getElementById('horaout').value;
	hora2=horamin2.substr(0,2);
	min2=horamin2.substr(3,2);
	fecha2=new Date(ano2,mes2,dia2,hora2,min2);
	if(!esfecha(dia2,mes2,ano2)){
		alert("Fecha de Salida incorrecta");
		return false;
	}
	if(fecha1<ahora){
		alert("Fecha de llegada anterior a HOY");
		return false;
	}
	if(fecha2<ahora){
		alert("Fecha de salida anterior a HOY");
		return false;
	}
	if(fecha2<fecha1){
		alert("Fecha de SALIDA anterior a LLEGADA");
		return false;
	}

	
}
function abreventana(url, nombre, width, height,to,le) {
	if(nombre=="" || nombre==undefined){
		nombre="vtn"
	}
	
	if(to=="" || to==undefined){
		to=60;
	}
	
	if(le=="" || le==undefined){
		le=150;
	}
	
      var win = window.open(url,nombre,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=0,menubar=0,status=0,top='+to+',left='+le);
	  win.window.focus();
       
}
function ventanasc(url, nombre, width, height,to,le) {
	if(nombre=="" || nombre==undefined){
		nombre="vtn"
	}
	
	if(to=="" || to==undefined){
		to=60;
	}
	
	if(le=="" || le==undefined){
		le=150;
	}
	
      var Win = window.open(url,nombre,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=1,menubar=0,status=0,top='+to+',left='+le);
	  Win.window.focus();
       
}
function seleccionar(grupo){
	/*if(window.opener.document.getElementById('grupo')){
		window.opener.document.getElementById('grupo').value=grupo;
		window.close();
	}else{*/
		if(confirm("¿Hacer una Reserva? \n Would you like to make a booking? \n Möchten Sie Reservieren?")){
			/*if(window.opener.document.getElementById('diain')){
				window.close();
			}else{*/
				window.opener.location='index.php?grupo='+grupo;
				window.close();
			//}
		}
	//}
}
function seleccionar_d(grupo){
	//if(window.opener.document.getElementById('grupo')){
		window.opener.document.getElementById('grupo').value=grupo;
		window.close();
	//}
	/*else{
		if(confirm("¿Hacer una Reserva? \n Would you like to make a booking? \n Möchten Sie Reservieren?")){
			if(window.opener.document.getElementById('diain')){
				window.close();
			}else{
				window.opener.location='index.php?grupo='+grupo;
				window.close();
			}
		}
	}*/
}function cantidad(nom,a){
	if(a){
		document.getElementById(nom).style.visibility=(document.layers) ?'show' : 'visible';
		document.getElementById(nom).value="1";
		
	}else{
		document.getElementById(nom).style.visibility= (document.layers) ? 'hide' : 'hidden';
	}
	sumastarifa();
}
function sumastarifa(){
	if(document.getElementById('preciodiv')){
		total=0;
		subtot=0;
		silla=0;
		elevador=0;
		baca=0;
		regalo=document.getElementById('diasregalo').value;
		if(regalo==""){
			regalo=0;
		}else{
			regalo=parseInt(document.getElementById('diasregalo').value);
		}
		total=parseFloat(document.getElementById('preciodiv').value)*(parseInt(document.getElementById('diasalq').value)-regalo);
		document.getElementById('subalq').value=(Math.round(total*100)/100).toFixed(2);
		if(document.getElementById('bebe').checked){
			silla=parseFloat(document.getElementById('preciosilla').value)*parseInt(document.getElementById('nsilla').value)*parseInt(document.getElementById('diasreales').value);
			total=total+silla;
		}
		if(document.getElementById('eleva').checked){
			elevador=parseFloat(document.getElementById('precioeleva').value)*parseInt(document.getElementById('neleva').value)*parseInt(document.getElementById('diasreales').value);
			total=total+elevador;
		}
		if(document.getElementById('baca').checked){
			baca=parseFloat(document.getElementById('preciobaca').value)*parseInt(document.getElementById('diasreales').value);
			total=total+baca;
		}
		document.getElementById('subext').value=(silla+elevador+baca+parseFloat(document.getElementById('preciomuelle').value)+parseFloat(document.getElementById('preciosuple').value)).toFixed(2);
		total=total+parseFloat(document.getElementById('preciomuelle').value)+parseFloat(document.getElementById('preciosuple').value);
		
		document.getElementById('total').value=(Math.round(total*100)/100).toFixed(2);
		
	}
}
function tiempo(){
	var miajax=ajax();
	miajax.open("POST","ajaxtime.php",true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=miajax.responseText;
			document.getElementById('s').value=txt;
		}
	}
	miajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	miajax.send("");
}



function control(){
	if(document.getElementById('aut')){
		document.getElementById('aut').value="SI";
		tiempo();
		if(!confirm("Se va a procesar su Reserva")){
			return false;
		}
	}
	if(document.getElementById('dni').value.length<1 || document.getElementById('dni').value=="DNI/NIE"){
		alert("Es obligatorio el DNI/NIE/Pasaporte");
		document.getElementById('dni').focus();
		return false;
	}
	
	if(document.getElementById('dianac')){
		if(document.getElementById('dianac').value=="---" || document.getElementById('mesnac').value=="---" || document.getElementById('anonac').value=="---"){
		alert("No es correcta la Fecha de Nacimiento");
		document.getElementById('dianac').focus();
		return false;
		}else{
			var ok=esfecha(document.getElementById('dianac').value,document.getElementById('mesnac').value-1,document.getElementById('anonac').value);
			if(!ok){
				alert("Esta Fecha de Nacimiento no existe");
				document.getElementById('dianac').focus();
				return false;
			}
		}
	}
	
	if(document.getElementById('fechanac')){
		if(document.getElementById('fechanac').value.length<1 ){
			alert("La Fecha de Nacimiento no puede estar vacia");
			document.getElementById('fechanac').focus();
			return false;
		}
	}
	
	if(document.getElementById('nombre').value.length<1 || document.getElementById('nombre').value=="nombre"){
		alert("Es obligatorio el poner el nombre");
		document.getElementById('nombre').focus();
		return false;
	}
	if(document.getElementById('ape1').value.length<1 || document.getElementById('ape1').value=="apellido 1"){
		alert("Es obligatorio el poner el 1º Apellido");
		document.getElementById('ape1').focus();
		return false;
	}
	
	/*if(document.getElementById('ape2').value.length<1 || document.getElementById('ape2').value=="apellido 2"){
		alert("Es obligatorio el poner el 2º Apellido");
		document.getElementById('ape2').focus();
		return false;
	}*/
	if(document.getElementById('movil').value=='telf. movil' || document.getElementById('movil').value.length<1){
		alert("Es obligatotrio un telf. móvil \nO en su defecto un tlf. fijo");
		document.getElementById('movil').focus();
		return false;
	}else{
		if(isNaN(document.getElementById('movil').value)){
			alert("El Móvil solo debe de tener números");
			document.getElementById('movil').focus();
			return false;
		}
	}
	
	if(document.getElementById('ciudad').value.length<1 || document.getElementById('ciudad').value=="ciudad"){
		alert("Es obligatorio el poner la Ciudad");
		document.getElementById('ciudad').focus();
		return false;
	}
	if(document.getElementById('pais').value.length<1 || document.getElementById('pais').value=="pais"){
		alert("Es obligatorio el poner el Pais");
		document.getElementById('pais').focus();
		return false;
	}
	if (document.getElementById("email2")){
		if (document.getElementById("email2").value.indexOf("@")==-1 || document.getElementById("email2").value.indexOf(".")==-1){
			alert("El E-mail no es correcto");
			document.getElementById('email2').focus();
			return false;
		}
	}
	if(document.getElementById('aut')){
		if(document.getElementById('pass1').disabled==false){
		
			if(document.getElementById('pass1').value.length>0 && document.getElementById('pass1').value.length<4){
				alert("Mínimo 4 caracteres para la contraseña");
				document.getElementById('pass1').focus();
				return false;
			}
		
			if(document.getElementById('pass1').value.length>=4){
				if(document.getElementById('pass1').value!=document.getElementById('pass2').value){
					alert("No coinciden las contraseñas");
					document.getElementById('pass1').value='';
					document.getElementById('pass2').value='';
					document.getElementById('pass1').focus();
					return false;
				}
		
			}
		}
	}
	
	if(document.getElementById('enviarusuario')){
		altausuario();
	}
}
function registro(email,pass,div){
	if (document.getElementById("email").value.indexOf("@")==-1 || document.getElementById("email").value.indexOf(".")==-1){
		alert("El E-mail no es correcto");
		document.getElementById('email').focus();
		return;
	}
	if(document.getElementById('pass').value.length<4){
		alert("Mínimo 4 caracteres para la contraseña");
		document.getElementById('pass').focus();
		return;
	}
	var destino=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxregistro.php?email="+email+"&pass="+pass,true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			if(txt=="NO"){
				alert("Usuario no registrado");
			}else{
				destino.innerHTML=txt;
				document.getElementById('pass1').disabled=true;
				document.getElementById('pass2').disabled=true;
			}
			
		}
	}
	miajax.send(null);	
}
function imagenes(){
	if(document.getElementById('pantalla')){
		document.getElementById('pantalla').src=ima[cont];
		document.images.pantalla.width=292;
		document.images.pantalla.height=173;
		cont++;
	if(cont==ima.length){
		cont=0;
	}
	}
}
function empresa(){
	if(document.getElementById('zona')){
		document.getElementById('zona').src=ima[cont];
		document.getElementById('zona').alt=txt[cont];
		document.getElementById('zona').title=txt[cont];
		//document.images.pantalla.width=292;
		//document.images.pantalla.height=173;
		cont++;
	if(cont==ima.length){
		cont=0;
	}
	}
}
function cuenta(div){
	if (document.getElementById("email").value.indexOf("@")==-1 || document.getElementById("email").value.indexOf(".")==-1){
		alert("El E-mail no es correcto");
		document.getElementById('email').focus();
		document.getElementById('email').style.color='#000000';
		document.getElementById('email').readOnly=false;
		document.getElementById('pass').readOnly=false;
		return;
	}
	if(document.getElementById('pass').value.length<4){
		alert("Mínimo 4 caracteres para la contraseña");
		document.getElementById('pass').focus();
		document.getElementById('email').style.color='#000000';
		document.getElementById('email').readOnly=false;
		document.getElementById('pass').readOnly=false;
		return;
	}
	email=document.getElementById("email").value;
	contra=document.getElementById("pass").value
	var destino=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxreservas.php?email="+email+"&pass="+contra+"&div="+div+"&ran="+Math.random(),true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			if(txt.indexOf("NOXX")>=0){
				alert("Usuario no registrado");
				document.getElementById('email').focus();
				document.getElementById('email').style.color='#000000';
				document.getElementById('email').readOnly=false;
				document.getElementById('pass').readOnly=false;
			}else{
				destino.innerHTML=txt;
			}
			
		}
	}
	miajax.send(null);	
}
function anulacion(id,div,idcon){
	if(!confirm("Se va a ANULAR la Reserva")){
		return;
	}
	
	var destino3=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxanular.php?id="+id+"&idcon="+idcon+"&div="+div,true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt)
			if(txt!="no"){
				destino3.innerHTML=txt;
				alert("Reserva anulada");
			}else{
				alert("No se pudo anular Inténtelo más tarde");	
			}
		}
	}
	miajax.send(null);
}
function vereserva(id,div,idcon){
	var destino2=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxvereserva.php?id="+id+"&idcon="+idcon+"&div="+div+"&ran="+Math.random(),true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt)
			if(txt!="no"){
				destino2.innerHTML=txt;
			}else{
				alert("No se pudo conectar con el servidor Inténtelo más tarde");	
			}
		}
	}
	miajax.send(null);
}
function modreserva(id,div,idcon){
	destino2=document.getElementById(div);
	hin=document.getElementById('horain').value;
	hout=document.getElementById('horaout').value;
	lin=document.getElementById('lugarin').value;
	lout=document.getElementById('lugarout').value;
	vvuelo=document.getElementById('vuelo').value;
	vdias=document.getElementById('dias').value;
	fecha11=document.getElementById('fechain').value;
	fecha21=document.getElementById('fechaout').value;
	miajax=ajax();
	miajax.open("GET","ajaxmodreserva.php?id="+id+"&idcon="+idcon+"&div="+div+"&hin="+hin+"&lin="+lin+"&hout="+hout+"&lout="+lout+"&vuelo="+vvuelo+"&dias="+vdias+"&fecha1="+fecha11+"&fecha2="+fecha21,true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt)
			if(txt!="no"){
				//destino2.innerHTML=txt;
				alert("Reserva modificada");
				cuenta(div);
			}else{
				alert("No se pudo conectar con el servidor Inténtelo más tarde");	
			}
		}
	}
	miajax.send(null);
}
function controldias(){
	//alert("uuu");
	if(document.getElementById('corte')){
		document.getElementById('corte').value="";
	}
	if(document.getElementById('fechain')){
		fecha1=document.getElementById('fechain').value;
		hora1=document.getElementById('horain').value;
		fecha2=document.getElementById('fechaout').value;
		hora2=document.getElementById('horaout').value;
		date1=new Date(fecha1.substr(6,4),parseInt(fecha1.substr(3,2))-1,fecha1.substr(0,2),hora1.substr(0,2),hora1.substr(3,2));
		date2=new Date(fecha2.substr(6,4),parseInt(fecha2.substr(3,2))-1,fecha2.substr(0,2),hora2.substr(0,2),hora2.substr(3,2));
	}
	if(document.getElementById('diain')){
		dia1=document.getElementById('diain').value;
		mes1=parseInt(document.getElementById('mesin').value)-1;
		ano1=document.getElementById('anoin').value;
		hora1=document.getElementById('horain').value;
		date1=new Date(ano1,mes1,dia1,hora1.substr(0,2),hora1.substr(3,2));
		dia2=document.getElementById('diaout').value;
		mes2=parseInt(document.getElementById('mesout').value)-1;
		ano2=document.getElementById('anoout').value;
		hora2=document.getElementById('horaout').value;
		date2=new Date(ano2,mes2,dia2,hora2.substr(0,2),hora2.substr(3,2));
	}
	time1=date1.getTime()/1000;
	t1=time1;
	time2=date2.getTime()/1000;
	t2=time2;
	if(time2<time1){
		alert("Fecha salida anterior a fecha llegada");	
		return;
	}
	dif=time2-time1;
	kdias=dif/86400;
	khoras=kdias-Math.floor(kdias);
	kdias=parseInt(kdias);
	cortesia="";
	if(kdias>=1){
		cortesia="s";
	}
	khoras=khoras*24;
	if(khoras>3){
		kdias++;	
		if(khoras>3 && khoras<5 && cortesia=="s"){
			if(document.getElementById('corte')){
				document.getElementById('corte').value="+1 día por pasar de 3 h. de cortesía";
			}
		}
	}
	if(kdias<1){
		kdias=1;	
	}
	document.getElementById('dias').value=kdias;
}
function recuperar(div){
	destino3=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxrecuperar.php?l="+Math.random(),true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt)
			destino3.innerHTML=txt;
		}
	}
	miajax.send(null);
}
function passw(){
	pdni=document.getElementById('dni').value;
	pfechanac=document.getElementById('fechanac').value;
	pemail=document.getElementById('email2').value;
	//destino3=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxpass.php?dni="+pdni+"&fechanac="+pfechanac+"&email="+pemail+"&l="+Math.random(),true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt)
			if(txt=="ok"){
				//destino2.innerHTML=txt;
				alert("Contraseña enviada");
				window.self.location="cuenta.php";
			}else{
				if(txt.indexOf("fecha")>=0){
					alert("Fecha Incorrecta");	
					document.getElementById('fechanac').focus();
				}
				if(txt=="no"){
					alert("No coinciden los datos");	
					document.getElementById('dni').focus()
				}
				if(txt=="xx"){
					alert("Imposible enviar el E-mail... inténtelo más tarde");	
					document.getElementById('dni').focus()
				}
			}
		}
	}
	miajax.send(null);
	
}
function controlrecuperar(fecha){
	fechahoy=new Date(); 
	anohoy=fechahoy.getFullYear()-18;
	anoayer=anohoy-85;
	ano=parseInt(fecha.substr(6,4));
	if(fecha.length!=10){
		alert("Longitud de la fecha incorrecta");
		return;
	}
	if(isNaN(ano)){
		alert("No es una fecha");
		return;
	}
	if(ano>anohoy || ano<anoayer){
		alert("Año fuera de rango\n"+anoayer+" - "+anohoy);
		return;
	}
	
}
function usuario(div){
	udestino3=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxusuario.php?l="+Math.random(),true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt)
			udestino3.innerHTML=txt;
		}
	}
	miajax.send(null);
}
function altausuario(){
	var unombre=document.getElementById('nombre').value;
	var ufechanac=document.getElementById('fechanac').value;
	var udni=document.getElementById('dni').value;
	var uape1=document.getElementById('ape1').value;
	var uape2=document.getElementById('ape2').value;
	var umovil=document.getElementById('movil').value;
	var uciudad=document.getElementById('ciudad').value;
	var upais=document.getElementById('pais').value;
	var uemail=document.getElementById('email2').value;
	var valores="nombre="+unombre+"&fechanac="+ufechanac+"&dni="+udni+"&ape1="+uape1+"&ape2="+uape2+"&movil="+umovil+"&ciudad="+uciudad+"&pais="+upais+"&email="+uemail;
	var miajax=ajax();
	miajax.open("POST","ajaxaltausuario.php",true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			var txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt);
			if(txt=="ok"){
				//destino2.innerHTML=txt;
				alert("Usuario registrado, contraseña enviada");
				window.self.location="cuenta.php";
			}else{
				if(txt.indexOf("fecha")>=0){
					alert("Fecha Incorrecta, menor de 21 años o mayor de 90");	
					document.getElementById('fechanac').focus();
				}
				if(txt=="nod"){
					alert("Ya existe el DNI/NIE pero no coinciden los datos. Revíselos");	
					document.getElementById('dni').focus();
				}
				if(txt=="noe"){
					alert("Usuario registrado pero no se pudo enviar el E-mail con la contraseña... \nrecuperala más tarde en el enlace de recuperar la contraseña");	
					window.self.location="cuenta.php";
				}
				if(txt=="noi" || txt=="nou"){
					alert("No se pudo registrar este usuario");	
					document.getElementById('dni').focus();
				}
				if(txt=="dni"){
					alert("Introduce el DNI/NIE");	
					document.getElementById('dni').focus();
				}
			}
		}
	}
	
	miajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	miajax.send(valores);
}
function datosusuario(div){
	zdestino3=document.getElementById(div);
	var miajax=ajax();
	miajax.open("GET","ajaxdatos.php?l="+Math.random(),true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt)
			zdestino3.innerHTML=txt;
		}
	}
	miajax.send(null);
}
function cambiardatos(){
	gdni=document.getElementById('dni').value;
	gpassant=document.getElementById('passant').value;
	gpass1=document.getElementById('pass1').value;
	gpass2=document.getElementById('pass2').value;
	gemail=document.getElementById('email2').value;
	if(gemail.length>1){
		if (document.getElementById("email2").value.indexOf("@")==-1 || document.getElementById("email2").value.indexOf(".")==-1){
			alert("El E-mail no es correcto");
			document.getElementById('email2').focus();
			return;
		}
	}
	
	valores="dni="+gdni+"&passant="+gpassant+"&pass1="+gpass1+"&pass2="+gpass2+"&email="+gemail;
	var miajax=ajax();
	miajax.open("POST","ajaxcambiardatos.php",true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt);
			if(txt=="ok"){
				//destino2.innerHTML=txt;
				alert("Datos actualizados correctamente");
				window.self.location="cuenta.php";
			}else{
				if(txt=="dni"){
					alert("El DNI/NIE es obligatorio");	
					document.getElementById('dni').focus();
				}
				if(txt=="pass"){
					alert("Debes de poner la contraseña antigua");	
					document.getElementById('passant').focus();
				}
				if(txt=="nada"){
					alert("Estan en blanco el nuevo E-mail y la nueva contraseña");	
					document.getElementById('pass1').focus();
				}
				if(txt=="no"){
					alert("No se pudo registrar este usuario");	
					document.getElementById('dni').focus();
				}
				if(txt=="nou"){
					alert("No existe este usuario");	
					document.getElementById('dni').focus();
				}
				if(txt=="contra"){
					alert("No coinciden las contraseñas, o tienen menos de 4 caracteres");	
					document.getElementById('pass1').focus();
				}
			}
		}
	}
	
	miajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	miajax.send(valores);
}
function res_2(gr,grs,di){
	if(document.getElementById('solodias').value<di){
		alert('La reserva debe de ser superior a '+di+' dias');
		return;
	}
	document.getElementById('grupo').value=gr;
	if(grs!=''){
		document.getElementById('gruposup').value=grs;
	}
	document.forms[0].submit();
}

function mens(){
	var ur=document.URL;
	if(ur.indexOf('index.php')!=-1){
		if(document.getElementById('mensajito').value=='33'){
			alert('No hay disponiblidad para este grupo de coches');
		}
	}
}
function cambio_foto(){
	var foto=new Array();
	foto[0]="http://www.acanariasonline.com/fotos_hoteles/princess1.jpg";
	foto[1]="http://www.acanariasonline.com/fotos_hoteles/maximina1.jpg";
	foto[2]="http://www.acanariasonline.com/fotos_hoteles/taburiente1.jpg";
	foto[3]="http://www.acanariasonline.com/fotos_hoteles/cancajos1.jpg";
	foto[4]="http://www.acanariasonline.com/fotos_hoteles/lasolas1.jpg";
	foto[5]="http://www.acanariasonline.com/fotos_hoteles/salinas1.jpg";
	foto[6]="http://www.acanariasonline.com/fotos_hoteles/lacaleta1.jpg";
	foto[7]="http://www.acanariasonline.com/fotos_hoteles/cascada1.jpg";
	foto[8]="http://www.acanariasonline.com/fotos_hoteles/promantica1.jpg";
	foto[9]="http://www.acanariasonline.com/fotos_hoteles/elcerrito1.jpg";
	var nm=Math.round(Math.random()*9);
	document.getElementById('caja').src=foto[nm];
}
function clicks(){
	var valores='';
	var miajax=ajax();
	miajax.open("POST","ajaxclickspubli.php",true);
	miajax.onreadystatechange=function() {
		if(miajax.readyState==4){
			txt=unescape(miajax.responseText);
			txt=txt.replace(/\+/gi," ");
			txt=txt.replace(/^\s+|\s+$/gi,"");
			//alert(txt);
			/*if(txt=="ok"){
				//destino2.innerHTML=txt;
				alert("Datos actualizados correctamente");
			}*/
			
		}
	}
	
	miajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
	miajax.send(valores);
}
	
