function cambiarHotel() {
   
	var area = document.reservaHotel.area.options[document.reservaHotel.area.selectedIndex].value;
    
   		if(document.reservaHotel.area.value==-1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Cualquiera<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Cualquiera<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==2) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Cualquiera<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <\/se'+'lect>';

		}
  	
   }

function cambiarHotelIngles() {
   
	var area = document.reservaHotel.area.options[document.reservaHotel.area.selectedIndex].value;
    
   		if(document.reservaHotel.area.value==-1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Anyone<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Anyone<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==2) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Anyone<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <\/se'+'lect>';

		}
  	
   }
function cambiarHotelFrances() {
   
	var area = document.reservaHotel.area.options[document.reservaHotel.area.selectedIndex].value;
    
   		if(document.reservaHotel.area.value==-1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Quelqu´un<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Quelqu´un<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==2) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Quelqu´un<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <\/se'+'lect>';

		}
  	
   }
function cambiarHotelAleman() {
   
	var area = document.reservaHotel.area.options[document.reservaHotel.area.selectedIndex].value;
    
   		if(document.reservaHotel.area.value==-1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Ausgewählt<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==1) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Ausgewählt<\/opt'+'ion> <opt'+'ion value="08__">Apartahotel Aguadulce<\/opt'+'ion> <\/se'+'lect>';

		}
   	
   		if(document.reservaHotel.area.value==2) {
			document.getElementById('hotelForm').innerHTML = '<sel'+'ect name="hotel" id="hotel"><opt'+'ion value="" selected="selected">Ausgewählt<\/opt'+'ion> <opt'+'ion value="02__">Hotel Don Ignacio<\/opt'+'ion>  <opt'+'ion value="09__">Hostal San José<\/opt'+'ion> <\/se'+'lect>';

		}
  	
   }



function contarDias(Hoy, Nav) {

      var mseg_dia=1000*60*60*24;
      var dias;
      
      if (Hoy.getMonth()==Nav.getMonth() && Hoy.getDate()>Nav.getDate());
          Nav.setFullYear(Nav.getFullYear());
      dias = Math.ceil((Nav.getTime()-Hoy.getTime())/(mseg_dia));
      
	  return dias;

}


function reservar() {
	var fechaHoy = new Date();
	var fechaActual = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
	var fechaInicial = new Date(document.reservaHotel.anyoL.value, document.reservaHotel.mesL.value-1, document.reservaHotel.diaL.value)
	var fechaFinal = new Date(document.reservaHotel.anyoS.value, document.reservaHotel.mesS.value-1, document.reservaHotel.diaS.value)
	var dias = contarDias(fechaInicial, fechaFinal);
	
	if(dias<0) {
		alert("La fecha final no puede ser porterior a la inicial");
	} else {
	  
		document.reservaHotel.DIn.value = document.reservaHotel.diaL.value + "/" + document.reservaHotel.mesL.value + "/" + document.reservaHotel.anyoL.value;
		document.reservaHotel.D.value = dias;

		if(fechaActual > fechaInicial) {
		   alert("La fecha inicial no puede ser anterior a la de hoy");
		} else {
//			document.reservaHotel.HC.value = document.reservaHotel.hotel.value;
			document.reservaHotel.HC.value = "";
			document.forms["reservaHotel"].submit();
		}
	}
}


function reservar2(valor) {

	var error = "";
	
	if(document.reservaConfirmada.nom.value =="") {
		error += "Debe de indicar rellernar el campo nombre.\n";
	}
	  
	if(document.reservaConfirmada.ape1.value =="") {
		error += "Debe de indicar rellernar el campo apellido 1.\n";
	}
	  
	if(document.reservaConfirmada.tel.value =="") {
		error += "Debe de indicar rellernar el campo telefono.\n";
	} else {
		 if (isNaN(document.reservaConfirmada.tel.value)) error+='El campo telefono debe ser un numero.\n';
	}
	if(document.reservaConfirmada.email.value =="") {
		
		error += "Debe de indicar rellernar el campo mail.\n";
	} else {
		p=(document.reservaConfirmada.email.value).indexOf('@');
          if (p<1)
		  	error+='El campo Mail debe ser una direccion de email.\n';
    }
		
 


if(error == "") {
//		document.reservaConfirmada.Name.value = document.reservaConfirmada.nom.value;
//		document.reservaConfirmada.SName.value = document.reservaConfirmada.ape1.value;
//		document.reservaConfirmada.Age.value = 18;

		document.reservaConfirmada.pagoBanco.value = valor;
		document.forms.reservaConfirmada.submit();

} else {
		alert(error);
	}

}

function ponerFechaEntrada() {
	var dia = document.getElementById("entrada").value.substring(0,2);
	var mes = document.getElementById("entrada").value.substring(3,5);
	var any = document.getElementById("entrada").value.substring(6,10);
	
	document.getElementById("diaL").selectedIndex = dia-1;
	document.getElementById("mesL").selectedIndex = mes-1;
	
	var fechaHoy = new Date();
	if(any==fechaHoy.getFullYear()) {
	 	document.getElementById("anyoL").selectedIndex = 0;
	} else {
		if(any==fechaHoy.getFullYear()+1)
		 	document.getElementById("anyoL").selectedIndex = 1;
		else
			alert("No es posible realizar la reserva en la fecha indicada.")
	}
}


function ponerFechaSalida() {
	var dia = document.getElementById("salida").value.substring(0,2);
	var mes = document.getElementById("salida").value.substring(3,5);
	var any = document.getElementById("salida").value.substring(6,10);
	
	document.getElementById("diaS").selectedIndex = dia-1;
	document.getElementById("mesS").selectedIndex = mes-1;
	
	var fechaHoy = new Date();
	if(any==fechaHoy.getFullYear()) {
	 	document.getElementById("anyoS").selectedIndex = 0;
	} else {
		if(any==fechaHoy.getFullYear()+1)
		 	document.getElementById("anyoS").selectedIndex = 1;
		else
			alert("No es posible realizar la reserva en la fecha indicada.")
	}
}

function prepagar(cantidad) {
	
	cantidaddes = document.reservaConfirmada.totalPago.value/100;
	if (cantidad.value=="min"){
//		document.reservaConfirmada.prepago.value=document.reservaConfirmada.totalPago.value*0.2;
		document.getElementById('prepagado').innerHTML = '<in'+'put name="prepago" id="prepago" type="text" value="' + (Math.round((cantidaddes*0.2)*100))/100 + '"" size="10" maxlength="8" /'+'>'
	}
	if (cantidad.value=="max"){
//		document.reservaConfirmada.prepago.value=document.reservaConfirmada.totalPago.value;
		document.getElementById('prepagado').innerHTML = '<in'+'put name="prepago" id="prepago" type="text" value="' + cantidaddes + '"" size="10" maxlength="8" /'+'>'
	}

	
}

function decimal(cantidad) {
	
	cantidaddes = document.reservaConfirmada.totalPago.value/100;
		document.getElementById('prepagado').innerHTML = '<in'+'put name="prepago" id="prepago" type="text" value="' + (Math.round((cantidaddes*0.2)*100))/100 + '"" size="10" maxlength="8" /'+'>'

	
}


function enviar() {
	
	var error = "";
	if(document.form1.Codigo_reserva.value=="") {
		error += "Debe introducir el codigo de reserva\n";
	}
	if(document.form1.email.value=="") {
		error += "Debe introducir el email";
	}
	
	if(error!="")
		alert(error);
	else
		document.form1.submit();
}

function fotosAguadulce(numero) {
	
	switch(numero) {
		case 1:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto1.jpg" width="536" height="349" \/>';
		break;    
		case 2:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto2.jpg" width="536" height="349" \/>';
		break;    
		case 3:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto3.jpg" width="536" height="349" \/>';
		break;    
		case 4:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto4.jpg" width="536" height="349" \/>';
		break;    
		case 5:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto5.jpg" width="536" height="349" \/>';
		break;    
		case 6:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto6.jpg" width="536" height="349" \/>';
		break;   
		case 7:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto7.jpg" width="536" height="349" \/>';
		break;   
		case 8:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto8.jpg" width="536" height="349" \/>';
		break;   
		case 9:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto9.jpg" width="536" height="349" \/>';
		break;   
		case 10:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto10.jpg" width="536" height="349" \/>';
		break;   
		case 11:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto11.jpg" width="536" height="349" \/>';
		break;   
		case 12:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Aparthotel Aguadulce" src="img/apartaguadulcefoto12.jpg" width="536" height="349" \/>';
		break;   
	}
}


function fotosSanJose(numero) {
	
	switch(numero) {
		case 1:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hostal San Jose" src="img/sanjosefoto1.jpg" width="536" height="349" \/>';
		break;    
		case 2:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hostal San Jose" src="img/sanjosefoto2.jpg" width="536" height="349" \/>';
		break;    
		case 3:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hostal San Jose" src="img/sanjosefoto3.jpg" width="536" height="349" \/>';
		break;    
		case 4:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hostal San Jose" src="img/sanjosefoto4.jpg" width="536" height="349" \/>';
		break;    
		case 5:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hostal San Jose" src="img/sanjosefoto5.jpg" width="536" height="349" \/>';
		break;    
		case 6:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hostal San Jose" src="img/sanjosefoto6.jpg" width="536" height="349" \/>';
		break;    
	}
}


function fotosDonIgnacio(numero) {
	
	switch(numero) {
		case 1:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto1.jpg" width="536" height="349" \/>';
		break;    
		case 2:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto2.jpg" width="536" height="349" \/>';
		break;    
		case 3:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto3.jpg" width="536" height="349" \/>';
		break;    
		case 4:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto4.jpg" width="536" height="349" \/>';
		break;    
		case 5:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto5.jpg" width="536" height="349" \/>';
		break;    
		case 6:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto6.jpg" width="536" height="349" \/>';
		break;    
		case 7:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto7.jpg" width="536" height="349" \/>';
		break;
		case 8:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto8.jpg" width="536" height="349" \/>';
		break; 
		case 9:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto9.jpg" width="536" height="349" \/>';
		break; 
		case 10:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto10.jpg" width="536" height="349" \/>';
		break; 
		case 11:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto11.jpg" width="536" height="349" \/>';
		break; 
		case 12:
		  document.getElementById('flash').innerHTML = '<im'+'g align="Hotel Don Ignacio" src="img/donignaciofoto12.jpg" width="536" height="349" \/>';
		break; 
	}
}

function enviarHotel(hotel) {
	var fechaHoy = new Date();
	var fechaActual = new Date(fechaHoy.getFullYear(), fechaHoy.getMonth(), fechaHoy.getDate());
	var fechaInicial = new Date(document.reservaHotel.anyoL.value, document.reservaHotel.mesL.value-1, document.reservaHotel.diaL.value)
	var fechaFinal = new Date(document.reservaHotel.anyoS.value, document.reservaHotel.mesS.value-1, document.reservaHotel.diaS.value)
	var dias = contarDias(fechaInicial, fechaFinal);
	
	  
		document.reservaHotel.DIn.value = document.reservaHotel.diaL.value + "/" + document.reservaHotel.mesL.value + "/" + document.reservaHotel.anyoL.value;
		document.reservaHotel.D.value = dias;

	document.reservaHotel.HC.value = hotel;
			document.forms["reservaHotel"].submit();
}


function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una dirección de Email.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' debe ser un numero.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
    } if (errors) alert('Han ocurrido los siguientes errores:\n'+errors);
    document.MM_returnValue = (errors == '');
} }
