//validar fechas
function Validform(MiFormulario){
		var date1 = document.getElementById("date1").value	
		var date2 = document.getElementById("date2").value
		//
		var hora1= document.getElementById("hora1").value
		var hora2= document.getElementById("hora2").value
		//
		long_fecha1=date1.length
		long_fecha2=date2.length
		array_fecha1=date1.split("/")
		array_fecha2=date2.split("/")
		//
		if ((long_fecha1<=0) ||(long_fecha2<=0)) {
			alert("Las fechas de RECOGIDA y DEVOLUCION, no pueden quedar en blanco.")			
			return false
		} else {
			initDate=new Date(array_fecha1[2], Number(array_fecha1[1]) - 1, array_fecha1[0])			
			endtDate=new Date(array_fecha2[2], Number(array_fecha2[1]) - 1, array_fecha2[0])
			if (endtDate<=initDate) {
				alert("La fecha de DEVOLUCION no puede ser MENOR que la fecha de RECOGIDA. O tienen que existir 24 horas de diferencia")			
				return false
			} else { 
				var one_day=1000*60*60*24
				var temp_hoy = new Date()
				var hoy =new Date(temp_hoy.getFullYear(), temp_hoy.getMonth(),temp_hoy.getDate(),0,0,0)
				//
				fourteen = ( ( endtDate.getTime()-initDate.getTime() )/(one_day) )
				two_days = ( ( initDate.getTime()-hoy.getTime() )/(one_day) )
				//
				//alert(two_days)
				if (fourteen>=15) {				
					alert("Para reservas de MAS de 15 DIAS, pongase en contacto con nuestras OFICINAS TEL. 93 510 29 68")
					return false
				}else if(two_days<2) {
					alert("No se pueden hacer reservas con menos de 48 horas de antelación, pongase en contacto con nuestras OFICINAS TEL. 93 510 29 68")
					return false
				}else {
					dia=initDate.getDate()
					dia_semana=initDate.getDay()
					mes=initDate.getMonth()
					//alert(dia)
					if (  ((dia==1||dia==6)&&mes==0)||(dia==1&&mes==4)||(dia==24&&mes==5)||(dia==15&&mes==7)||((dia==11||dia==24)&&mes==8)||(dia==12&&mes==9)||(dia==1&&mes==10)||((dia==6||dia==8||dia==25||dia==26)&&mes==11)   ) {
						alert("El día de recogida es FESTIVO, por favor, seleccione un nuevo día para la recogida del vehículo.")
						return false
					} else if (dia_semana==0) {
						alert("Nuestras oficinas permanecerán cerradas los DOMINGOS, por favor seleccione un nuevo día para la recogida del vehículo")
						return false
					} else if ((dia_semana==6)) {
						if ((hora1<10)||(hora1>13)) {
							alert("Los SABADOS, nuestro horario de oficina es de 10:00 a 13:00. Por favor seleccione otra hora de recogida del vehículo")
							return false
						}else{
							return true
						}						
					}else  {
						if ((hora1<9)||((hora1>14)&&(hora1<16))||((hora1>20))) {
							alert("Nuestro horario de oficina es de 8:30 a 13:30 y de 16:00 a 19:00. Por favor seleccione otra hora de recogida del vehículo")
							return false
						} else {							
							return true
						}
					}
				}				
			}
		}
}
//validar seleccion de vehiculo
function Selec_Vehiculo(MiFormulario){
	var marcado = false;	
	with (document.sel_vehiculo){
		num_vehiculos=ID_MODELO.length
		if (isNaN(num_vehiculos)) {
			num_vehiculos=1			
		}
		//
		if (num_vehiculos<2) {
			if (document.sel_vehiculo.ID_MODELO.checked) {
				//alert("marcado vehiculo solo")
				marcado=true
				return true
			}			
		}else {
			for ( var i = 0; i < num_vehiculos; i++ ) {
				if ( ID_MODELO[i].checked ) {
					//alert ("Su vehículo es el: " + ID_PRODUCTO[i].value);
					marcado=true
					return true;
				}
			}
		}
		if ( marcado == false ){
			window.alert("Debe seleccionar un vehículo." ) ;
			return false
		}
	}

}

		
	
	