function checkContact(){
	var politica = document.getElementById("politica").checked;
	var nombre=document.getElementById("nombre").value;
	var apellidos=document.getElementById("apellidos").value;
	var email=document.getElementById("email").value;
	var telefono=document.getElementById("telefono").value;
	var comentarios=document.getElementById("comentarios").value;
	
	//comprueba que los campos estan rellenados
	if(nombre==""){
		alert("Debe indicar su nombre");
	}else if(email==""){
		alert("Debe indicar un email");
	}else if(comentarios==""){
		alert("Debe indicar el motivo de la Consulta");
	}else if(politica==false){
		alert("Debe aceptar la política de privacidad");
	}else{
		document.getElementById("formContacto").submit();
	}
}
function checkReserva(){
	/* Paso 1 */
	var diaRecogida=new Date(document.getElementById("fechaEntregaReserva_Year_ID").value,document.getElementById("fechaEntregaReserva_Month").value,document.getElementById("fechaEntregaReserva_Day_ID").value);	
	var diaEntrega=new Date(document.getElementById("fechaRecogidaReserva_Year_ID").value,document.getElementById("fechaRecogidaReserva_Month").value,document.getElementById("fechaRecogidaReserva_Day_ID").value);
	var diferencia = diaEntrega.getTime() - diaRecogida.getTime();
	var dias = Math.round(diferencia / (1000 * 60 * 60 * 24));
	
	var lEntrega=document.getElementById("lugarEntregaR").value;
	var fEntrega=document.getElementById("fechaEntregaReserva").value;
	var hEntrega=document.getElementById("horaEntregaR").value;
	var mEntrega=document.getElementById("minutoEntregaR").value;
	var lRecogida=document.getElementById("lugarRecogidaR").value;
	var fRecogida=document.getElementById("fechaRecogidaReserva").value;
	var hRecogida=document.getElementById("horaRecogidaR").value;
	var mRecogida=document.getElementById("minutoRecogidaR").value;
	
	/* Paso 2 */
	var marca=document.getElementById("marcaR").value;
	var modelo=document.getElementById("modeloR").value;
	var color=document.getElementById("colorR").value;
	var matricula=document.getElementById("matriculaR").value;
	
	/*Paso 3*/
	var nombre=document.getElementById("nombreR").value;
	var apellidos=document.getElementById("apellidosR").value;
	var email=document.getElementById("emailR").value;
	var telefono=document.getElementById("telefonoR").value;
	var direccion=document.getElementById("direccionR").value;
	var municipio=document.getElementById("municipioR").value;
	var provincia=document.getElementById("provinciaR").value;
	var pais=document.getElementById("paisR").value;
	var direccionLocal="";
	var municipioLocal="";
	var provinciaLocal="";
	var dni=document.getElementById("dniR").value;
	var diaDni="";
	var mesDni="";
	var anoDni="";
	var lugarDni="";
	var permiso=document.getElementById("permisoR").value;
	var diaPermiso="";
	var mesPermiso="";
	var anoPermiso="";
	var lugarPermiso="";
	var comentarios=document.getElementById("comentariosR").value;
	
	if(dias<0){
		alert("Introduzca las fechas correctamente.");
	}else if(lEntrega=="Por favor, selecciona"){
		window.location.href="#paso1";
		alert("Debe indicar un lugar de Entrada");
	}else if(lRecogida=="Por favor, selecciona"){
		window.location.href="#paso1";
		alert("Debe indicar un lugar de Salida");
	}else if(dias<=0){
		window.location.href="#paso1";
		alert("La fecha introducida es incorrecta");
	}else if(hEntrega=="--" || mEntrega=="--"){
		window.location.href="#paso1";
		alert("Debe indicar una hora de Entrada");
	}else if(hRecogida=="--" || mRecogida=="--"){
		window.location.href="#paso1";
		alert("Debe indicar una hora de Salida");
	}else if(marca=="" || modelo=="" || color=="" || matricula==""){
		window.location.href="#paso2";
		alert("Debe indicar todos los datos del vehiculo");
	}else if(nombre==""){
		alert("Debe indicar su nombre");
	}else if(apellidos==""){
		alert("Debe indicar sus apellidos");
	}else if(email==""){
		alert("Debe indicar su email");
	}else if(telefono==""){
		alert("Debe indicar su teléfono");
	}else if(direccion=="" || municipio=="" || provincia=="" || pais=="Por favor, selecciona"){
		alert("Debe indicar su domicilio habitual: dirección, municipio, provincia y país");
	}else if(dni==""){
		alert("Debe indicar su DNI.");
	}else if(permiso==""){
		alert("Debe indicar su Permiso de Conducir");
	}else{
		document.getElementById("formReservaOnline").submit();
	}
}
function presupost(){
	var extraLugar = document.getElementById("lugarEntregaR").value;
	var extraLugarR = document.getElementById("lugarRecogidaR").value;
	var diaRecogida=document.getElementById("fechaEntregaReserva_Year_ID").value+"-"+document.getElementById("fechaEntregaReserva_Month").value+"-"+document.getElementById("fechaEntregaReserva_Day_ID").value;	
	var diaEntrega=document.getElementById("fechaRecogidaReserva_Year_ID").value+"-"+document.getElementById("fechaRecogidaReserva_Month").value+"-"+document.getElementById("fechaRecogidaReserva_Day_ID").value;
	var hEntrega=document.getElementById("horaEntregaR").value;
	var hRecogida=document.getElementById("horaRecogidaR").value;
	
	$.ajax({
        type: "POST",
        url: "../library/php/common_fns.php",
        data: "pre=si&diaIni="+diaRecogida+"&diaFin="+diaEntrega+"&horaIni="+hEntrega+"&horaFin="+hRecogida+"&extraLugar="+extraLugar+"&extraLugarR="+extraLugarR,
        success: function(datos){
       	$("#precio").html(datos+",00");
      }
	});
}
