// JavaScript Document


//revision de los campos obligatorios del formulario de contacto

function enviar(){
	
	check = window.document.forms[0].check.value;
	nombre = window.document.forms[0].nombre.value;
	email = window.document.forms[0].email.value;
	telefono = window.document.forms[0].telefono.value;
	movil = window.document.forms[0].movil.value;
	comentario = window.document.forms[0].comentario.value;
	auto = window.document.forms[0].auto.value;
	
	//Comprobamos que esten rellenos los campos obligatorios

	if (nombre == ""){
		msg = "Introduzca su Nombre";
		alert(msg);
		window.document.forms[0].nombre.focus();
		window.document.forms[0].nombre.select();
		return false;
	}
	
	
	if (email == ""){
		msg = "E-mail es obligatorio";
		alert(msg);
		window.document.forms[0].email.focus();
		window.document.forms[0].email.select();
		return false;
	}	
	
		if (telefono == ""){
		msg = "El telefono es obligatorio";
		alert(msg);
		window.document.forms[0].telefono.focus();
		window.document.forms[0].telefono.select();
		return false;
	}

	
	window.document.forms[0].submit();
}


//revision de los campos obligatorios del formulario de reservas

function reservar(){
	
	check = window.document.forms[0].check.value;
	nombre = window.document.forms[0].nombre.value;
	apellidos = window.document.forms[0].apellidos.value;
	dni = window.document.forms[0].dni.value;
	direccion = window.document.forms[0].direccion.value;
	postal = window.document.forms[0].postal.value;
	provincia = window.document.forms[0].provincia.value;
	email = window.document.forms[0].email.value;
	telefono = window.document.forms[0].telefono.value;
	
	marca = window.document.forms[0].marca.value;
	color = window.document.forms[0].color.value;
	modelo = window.document.forms[0].modelo.value;
	matricula = window.document.forms[0].matricula.value;
	
	fecha_recogida = window.document.forms[0].fecha_recogida.value;
	hora_recogida = window.document.forms[0].hora_recogida.value;
	aerolinea_recogida = window.document.forms[0].aerolinea_recogida.value;
	nro_vuelo_recogida = window.document.forms[0].nro_vuelo_recogida.value;
	terminal_recogida = window.document.forms[0].terminal_recogida.value;
	destino_recogida = window.document.forms[0].destino_recogida.value;

	fecha_entrega = window.document.forms[0].fecha_entrega.value;
	hora_entrega = window.document.forms[0].hora_entrega.value;
	aerolinea_entrega = window.document.forms[0].aerolinea_entrega.value;
	nro_vuelo_entrega = window.document.forms[0].nro_vuelo_entrega.value;
	terminal_entrega = window.document.forms[0].terminal_entrega.value;

	nombre_empresa = window.document.forms[0].nombre_empresa.value;
	cif = window.document.forms[0].cif.value;
	direccion_empresa = window.document.forms[0].direccion_empresa.value;
	comentario = window.document.forms[0].comentario.value;

	auto = window.document.forms[0].auto.value;
	
	//Comprobamos que esten rellenos los campos obligatorios

	if (nombre == ""){
		msg = "Introduzca su Nombre";
		alert(msg);
		window.document.forms[0].nombre.focus();
		window.document.forms[0].nombre.select();
		return false;
	}
	
	if (apellido == ""){
		msg = "Introduzca su Apellido";
		alert(msg);
		window.document.forms[0].apellido.focus();
		window.document.forms[0].apellido.select();
		return false;
	}
	
	if (dni == ""){
		msg = "Introduzca su DNI o NIE";
		alert(msg);
		window.document.forms[0].dni.focus();
		window.document.forms[0].dni.select();
		return false;
	}
	
	if (provincia == ""){
		msg = "Introduzca la Provincia";
		alert(msg);
		window.document.forms[0].provincia.select();
		return false;
	}

	if (telefono == ""){
		msg = "Introduzca su telefono movil";
		alert(msg);
		window.document.forms[0].telefono.focus();
		window.document.forms[0].telefono.select();
		return false;
	}	


			if (email == ""){
				msg = "E-mail es un campo obligatorio";
				alert(msg);
				window.document.forms[0].email.focus();
				window.document.forms[0].email.select();
				return false;
			} else {
				re = new RegExp("^[A-Za-z0-9_.\-]+@[A-Za-z0-9_.\-]+\\.[A-Za-z0-9_\-]+$"); //letras con 'A-Za-z0-9_.' @ letras con 'A-Za-z0-9_.' . letras con 'A-Za-z0-9_.'
	//			re = new RegExp(".@.");			//qualquier cosa @ qualquier cosa
				if (!re.test(email)) {
				alert("Dirección de email incorrecta");
				window.document.forms[0].email.focus();
				return false;
				}
			}
	
		if (marca == ""){
		msg = "La marca del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].marca.focus();
		window.document.forms[0].marca.select();
		return false;
	}

		if (color == ""){
		msg = "El color del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].color.focus();
		window.document.forms[0].color.select();
		return false;
	}
	
		if (modelo == ""){
		msg = "El modelo del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].modelo.focus();
		window.document.forms[0].modelo.select();
		return false;
	}
	
		if (matricula == ""){
		msg = "La matricula del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].matricula.focus();
		window.document.forms[0].matricula.select();
		return false;
	}

		if (fecha_recogida == ""){
		msg = "La fecha de recogida del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].fecha_recogida.focus();
		window.document.forms[0].fecha_recogida.select();
		return false;
	}

		if (hora_recogida == ""){
		msg = "La hora de recogida del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].hora_recogida.focus();
		window.document.forms[0].hora_recogida.select();
		return false;
	}

		if (nro_vuelo_recogida == ""){
		msg = "El numero de vuelo es un campo obligatorio";
		alert(msg);
		window.document.forms[0].nro_vuelo_recogida.focus();
		window.document.forms[0].nro_vuelo_recogida.select();
		return false;
	}

		if (terminal_recogida == ""){
		msg = "El terminal de salida es un campo obligatorio";
		alert(msg);
		window.document.forms[0].terminal_recogida.focus();
		window.document.forms[0].terminal_recogida.select();
		return false;
	}

		if (destino_recogida == ""){
		msg = "El destino de su vuelo de salida es un campo obligatorio";
		alert(msg);
		window.document.forms[0].destino_recogida.focus();
		window.document.forms[0].destino_recogida.select();
		return false;
	}
	
		if (fecha_entrega == ""){
		msg = "La fecha de entrega del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].fecha_entrega.focus();
		window.document.forms[0].fecha_entrega.select();
		return false;
	}

		if (hora_entrega == ""){
		msg = "La hora de entrega del coche es un campo obligatorio";
		alert(msg);
		window.document.forms[0].hora_entrega.focus();
		window.document.forms[0].hora_entrega.select();
		return false;
	}

		if (nro_vuelo_entrega == ""){
		msg = "El numero de vuelo de llegada es un campo obligatorio";
		alert(msg);
		window.document.forms[0].nro_vuelo_entrega.focus();
		window.document.forms[0].nro_vuelo_entrega.select();
		return false;
	}

		if (terminal_entrega == ""){
		msg = "El terminal de llegada es un campo obligatorio";
		alert(msg);
		window.document.forms[0].terminal_entrega.focus();
		window.document.forms[0].terminal_entrega.select();
		return false;
	}


window.document.forms[0].submit();
}


//revision de los campos obligatorios del formulario de contacto en ingles

function enviar_eng(){
	
	check = window.document.forms[0].check.value;
	nombre = window.document.forms[0].nombre.value;
	email = window.document.forms[0].email.value;
	telefono = window.document.forms[0].telefono.value;
	movil = window.document.forms[0].movil.value;
	comentario = window.document.forms[0].comentario.value;
	auto = window.document.forms[0].auto.value;
	
	//Comprobamos que esten rellenos los campos obligatorios

	if (nombre == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].nombre.focus();
		window.document.forms[0].nombre.select();
		return false;
	}
	
	
	if (email == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].email.focus();
		window.document.forms[0].email.select();
		return false;
	}	
	
		if (telefono == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].telefono.focus();
		window.document.forms[0].telefono.select();
		return false;
	}

	
	window.document.forms[0].submit();
}


//revision de los campos obligatorios del formulario de reservas en ingles

function reservar_eng(){
	
	check = window.document.forms[0].check.value;
	nombre = window.document.forms[0].nombre.value;
	apellidos = window.document.forms[0].apellidos.value;
	dni = window.document.forms[0].dni.value;
	direccion = window.document.forms[0].direccion.value;
	postal = window.document.forms[0].postal.value;
	provincia = window.document.forms[0].provincia.value;
	email = window.document.forms[0].email.value;
	telefono = window.document.forms[0].telefono.value;
	
	marca = window.document.forms[0].marca.value;
	color = window.document.forms[0].color.value;
	modelo = window.document.forms[0].modelo.value;
	matricula = window.document.forms[0].matricula.value;
	
	fecha_recogida = window.document.forms[0].fecha_recogida.value;
	hora_recogida = window.document.forms[0].hora_recogida.value;
	aerolinea_recogida = window.document.forms[0].aerolinea_recogida.value;
	nro_vuelo_recogida = window.document.forms[0].nro_vuelo_recogida.value;
	terminal_recogida = window.document.forms[0].terminal_recogida.value;
	destino_recogida = window.document.forms[0].destino_recogida.value;

	fecha_entrega = window.document.forms[0].fecha_entrega.value;
	hora_entrega = window.document.forms[0].hora_entrega.value;
	aerolinea_entrega = window.document.forms[0].aerolinea_entrega.value;
	nro_vuelo_entrega = window.document.forms[0].nro_vuelo_entrega.value;
	terminal_entrega = window.document.forms[0].terminal_entrega.value;

	nombre_empresa = window.document.forms[0].nombre_empresa.value;
	cif = window.document.forms[0].cif.value;
	direccion_empresa = window.document.forms[0].direccion_empresa.value;
	comentario = window.document.forms[0].comentario.value;

	auto = window.document.forms[0].auto.value;
	
	//Comprobamos que esten rellenos los campos obligatorios

	if (nombre == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].nombre.focus();
		window.document.forms[0].nombre.select();
		return false;
	}
	
	if (apellido == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].apellido.focus();
		window.document.forms[0].apellido.select();
		return false;
	}
	
	if (dni == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].dni.focus();
		window.document.forms[0].dni.select();
		return false;
	}
	
	if (provincia == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].provincia.select();
		return false;
	}

	if (telefono == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].telefono.focus();
		window.document.forms[0].telefono.select();
		return false;
	}	


			if (email == ""){
				msg = "Required field";
				alert(msg);
				window.document.forms[0].email.focus();
				window.document.forms[0].email.select();
				return false;
			} else {
				re = new RegExp("^[A-Za-z0-9_.\-]+@[A-Za-z0-9_.\-]+\\.[A-Za-z0-9_\-]+$"); //letras con 'A-Za-z0-9_.' @ letras con 'A-Za-z0-9_.' . letras con 'A-Za-z0-9_.'
	//			re = new RegExp(".@.");			//qualquier cosa @ qualquier cosa
				if (!re.test(email)) {
				alert("Wrong email address");
				window.document.forms[0].email.focus();
				return false;
				}
			}
	
		if (marca == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].marca.focus();
		window.document.forms[0].marca.select();
		return false;
	}

		if (color == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].color.focus();
		window.document.forms[0].color.select();
		return false;
	}
	
		if (modelo == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].modelo.focus();
		window.document.forms[0].modelo.select();
		return false;
	}
	
		if (matricula == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].matricula.focus();
		window.document.forms[0].matricula.select();
		return false;
	}

		if (fecha_recogida == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].fecha_recogida.focus();
		window.document.forms[0].fecha_recogida.select();
		return false;
	}

		if (hora_recogida == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].hora_recogida.focus();
		window.document.forms[0].hora_recogida.select();
		return false;
	}

		if (nro_vuelo_recogida == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].nro_vuelo_recogida.focus();
		window.document.forms[0].nro_vuelo_recogida.select();
		return false;
	}

		if (terminal_recogida == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].terminal_recogida.focus();
		window.document.forms[0].terminal_recogida.select();
		return false;
	}

		if (destino_recogida == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].destino_recogida.focus();
		window.document.forms[0].destino_recogida.select();
		return false;
	}
	
		if (fecha_entrega == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].fecha_entrega.focus();
		window.document.forms[0].fecha_entrega.select();
		return false;
	}

		if (hora_entrega == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].hora_entrega.focus();
		window.document.forms[0].hora_entrega.select();
		return false;
	}

		if (nro_vuelo_entrega == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].nro_vuelo_entrega.focus();
		window.document.forms[0].nro_vuelo_entrega.select();
		return false;
	}

		if (terminal_entrega == ""){
		msg = "Required field";
		alert(msg);
		window.document.forms[0].terminal_entrega.focus();
		window.document.forms[0].terminal_entrega.select();
		return false;
	}


window.document.forms[0].submit();
}

//revision de los campos obligatorios del formulario de contacto en catalan

function enviar_cat(){
	
	check = window.document.forms[0].check.value;
	nombre = window.document.forms[0].nombre.value;
	email = window.document.forms[0].email.value;
	telefono = window.document.forms[0].telefono.value;
	movil = window.document.forms[0].movil.value;
	comentario = window.document.forms[0].comentario.value;
	auto = window.document.forms[0].auto.value;
	
	//Comprobamos que esten rellenos los campos obligatorios

	if (nombre == ""){
		msg = "Introduzca su Nombre";
		alert(msg);
		window.document.forms[0].nombre.focus();
		window.document.forms[0].nombre.select();
		return false;
	}
	
	
	if (email == ""){
		msg = "E-mail es obligatorio";
		alert(msg);
		window.document.forms[0].email.focus();
		window.document.forms[0].email.select();
		return false;
	}	
	
		if (telefono == ""){
		msg = "El telefono es obligatorio";
		alert(msg);
		window.document.forms[0].telefono.focus();
		window.document.forms[0].telefono.select();
		return false;
	}

	
	window.document.forms[0].submit();
}



//revision de los campos obligatorios del formulario de reservas en catalan

function reservar_cat(){
	
	check = window.document.forms[0].check.value;
	nombre = window.document.forms[0].nombre.value;
	apellidos = window.document.forms[0].apellidos.value;
	dni = window.document.forms[0].dni.value;
	direccion = window.document.forms[0].direccion.value;
	postal = window.document.forms[0].postal.value;
	provincia = window.document.forms[0].provincia.value;
	email = window.document.forms[0].email.value;
	telefono = window.document.forms[0].telefono.value;
	
	marca = window.document.forms[0].marca.value;
	color = window.document.forms[0].color.value;
	modelo = window.document.forms[0].modelo.value;
	matricula = window.document.forms[0].matricula.value;
	
	fecha_recogida = window.document.forms[0].fecha_recogida.value;
	hora_recogida = window.document.forms[0].hora_recogida.value;
	aerolinea_recogida = window.document.forms[0].aerolinea_recogida.value;
	nro_vuelo_recogida = window.document.forms[0].nro_vuelo_recogida.value;
	terminal_recogida = window.document.forms[0].terminal_recogida.value;
	destino_recogida = window.document.forms[0].destino_recogida.value;

	fecha_entrega = window.document.forms[0].fecha_entrega.value;
	hora_entrega = window.document.forms[0].hora_entrega.value;
	aerolinea_entrega = window.document.forms[0].aerolinea_entrega.value;
	nro_vuelo_entrega = window.document.forms[0].nro_vuelo_entrega.value;
	terminal_entrega = window.document.forms[0].terminal_entrega.value;

	nombre_empresa = window.document.forms[0].nombre_empresa.value;
	cif = window.document.forms[0].cif.value;
	direccion_empresa = window.document.forms[0].direccion_empresa.value;
	comentario = window.document.forms[0].comentario.value;

	auto = window.document.forms[0].auto.value;
	
	//Comprobamos que esten rellenos los campos obligatorios

	if (nombre == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].nombre.focus();
		window.document.forms[0].nombre.select();
		return false;
	}
	
	if (apellido == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].apellido.focus();
		window.document.forms[0].apellido.select();
		return false;
	}
	
	if (dni == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].dni.focus();
		window.document.forms[0].dni.select();
		return false;
	}
	
	if (provincia == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].provincia.select();
		return false;
	}

	if (telefono == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].telefono.focus();
		window.document.forms[0].telefono.select();
		return false;
	}	


			if (email == ""){
				msg = "Campo obligatorio";
				alert(msg);
				window.document.forms[0].email.focus();
				window.document.forms[0].email.select();
				return false;
			} else {
				re = new RegExp("^[A-Za-z0-9_.\-]+@[A-Za-z0-9_.\-]+\\.[A-Za-z0-9_\-]+$"); //letras con 'A-Za-z0-9_.' @ letras con 'A-Za-z0-9_.' . letras con 'A-Za-z0-9_.'
	//			re = new RegExp(".@.");			//qualquier cosa @ qualquier cosa
				if (!re.test(email)) {
				alert("Email incorrecto");
				window.document.forms[0].email.focus();
				return false;
				}
			}
	
		if (marca == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].marca.focus();
		window.document.forms[0].marca.select();
		return false;
	}

		if (color == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].color.focus();
		window.document.forms[0].color.select();
		return false;
	}
	
		if (modelo == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].modelo.focus();
		window.document.forms[0].modelo.select();
		return false;
	}
	
		if (matricula == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].matricula.focus();
		window.document.forms[0].matricula.select();
		return false;
	}

		if (fecha_recogida == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].fecha_recogida.focus();
		window.document.forms[0].fecha_recogida.select();
		return false;
	}

		if (hora_recogida == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].hora_recogida.focus();
		window.document.forms[0].hora_recogida.select();
		return false;
	}

		if (nro_vuelo_recogida == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].nro_vuelo_recogida.focus();
		window.document.forms[0].nro_vuelo_recogida.select();
		return false;
	}

		if (terminal_recogida == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].terminal_recogida.focus();
		window.document.forms[0].terminal_recogida.select();
		return false;
	}

		if (destino_recogida == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].destino_recogida.focus();
		window.document.forms[0].destino_recogida.select();
		return false;
	}
	
		if (fecha_entrega == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].fecha_entrega.focus();
		window.document.forms[0].fecha_entrega.select();
		return false;
	}

		if (hora_entrega == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].hora_entrega.focus();
		window.document.forms[0].hora_entrega.select();
		return false;
	}

		if (nro_vuelo_entrega == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].nro_vuelo_entrega.focus();
		window.document.forms[0].nro_vuelo_entrega.select();
		return false;
	}

		if (terminal_entrega == ""){
		msg = "Campo obligatorio";
		alert(msg);
		window.document.forms[0].terminal_entrega.focus();
		window.document.forms[0].terminal_entrega.select();
		return false;
	}


window.document.forms[0].submit();
}

function borrar(){
	window.document.forms[0].reset();
}


