function validaFechas(){
	
	fechaI = document.getElementById("fechaI");
	fechaF = document.getElementById("fechaF");
	concec= document.getElementById("concec");
	if(concec == null ||concec.value=="" || concec.value==null){
	if(fechaI.value == "" || fechaF.value == ""){
		alert("Debe seleccionar un rango de fechas."); 
		return false;
	}
	}
	 return true;

	
}

 




function validaHoras(){
	
	horaI = document.getElementById("horaI");
	horaF = document.getElementById("horaF");
	
		
	if(horaI.value != "-1"){
		
		if(horaF.value=="-1"){
			alert("Debe seleccionar la hora final.");
			return false;
		}
	}
	if(horaF.value != "-1"){
		if(horaI.value=="-1"){
			alert("Debe seleccionar la hora Inicial");
			return false;
		}
	}
	
	if(horaI.value=="-1" || horaF.value=="-1"){
		alert("Debe seleccionar un rango de horas");
		return false;
	}
	return true;
	
	
	
}

function validaEstacion(){
	
	estacion = document.getElementById("estacion");

	
	if(estacion.value == "-1"){
		alert("Debe seleccionar una Estación");
		return false;
	}else{
		return true;
	}
		
}
function validaIncidente(){
	
	tipo = document.getElementById("tipoIncidente");

	
	if(tipo.value == "-1"){
		alert("Debe seleccionar un tipo de incidente"); 
		return false;
	}else{
		return true;
	}
		
}

function validaProvincia(){
	
	tipo = document.getElementById("Provincia");

	
	if(tipo.value == "-1"){
		alert("Debe seleccionar una provincia"); 
		return false;
	}else{
		return true;
	}
		
}

function validaBusqueda(formulario){
	
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	if(!validaFechas()){
		return false;
	}
	if(horaI.value != "-1" || horaF.value != "-1"){
		if(!validaHoras()){
			return false;
		}
	}
	form= document.getElementById(formulario);
	form.submit();
}

function validaBusquedaBIN(formulario){
	
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var conc = document.getElementById("concec");
	var anio = document.getElementById("anio");
	if(conc.value == "" && anio.value == "-1")
		if(!validaFechas()){
			return false;
		}
	if(horaI.value != "-1" || horaF.value != "-1"){
		if(!validaHoras()){
			return false;
		}
	}
	if(conc.value != "" && anio.value == "-1"){
		alert("La búsqueda por consecutivo requiere la selección del año");
		return false;
	}
	if(conc.value == "" && anio.value != "-1"){
		alert("Al buscar por año se debe digitar el consecutivo");
		return false;
	}
	form= document.getElementById(formulario);
	form.submit();
}

function validaBusquedaAct(form){
	if(!validaFechas()){
		return false;
	}
	
	if(document.formEsta.tipo[0].checked){ 
		tipo = 0;
	}else{
		tipo = 1;
	}
	var combo=document.getElementById("estacion").value;
	if(tipo==1){
		if(combo=="-1"){
			alert("Debe seleccionar una estación");
		}
		
	}
	form= document.getElementById(form);
	
	
	
	form.submit();
	
}

function validaConsecutivo(){
	var conc = document.getElementById("concec");
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var anio = document.getElementById("anio");
	var minI = document.getElementById("minI");
	var minF = document.getElementById("minF");
	
	if(conc.value=="" && anio.value == "-1"){
		tipo.disabled=false;
		est.disabled=false;
		horaI.disabled=false;
		horaF.disabled=false;
		minI.disabled=false;
		minF.disabled=false;
		prov.disabled=false;
		anio.disabled= false;
	}else{
		tipo.disabled=true;
		est.disabled=true;
		horaI.disabled=true;
		horaF.disabled=true;
		minI.disabled=true;
		minF.disabled=true;
		prov.disabled=true;
		anio.disabled= false;
	}
	
}

function validaConsecutivoConFecha(){
	var conc = document.getElementById("concec");
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var minI = document.getElementById("minI");
	var minF = document.getElementById("minF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var anio = document.getElementById("anio");
	if(anio.value=="-1" && conc.value==""){
		tipo.disabled=false;
		est.disabled=false;
		horaI.disabled=false;
		horaF.disabled=false;
		minI.disabled=false;
		minF.disabled=false;
		prov.disabled=false;
	}else{
		tipo.disabled=true;
		est.disabled=true;
		horaI.disabled=true;
		horaF.disabled=true;
		minI.disabled=true;
		minF.disabled=true;
		prov.disabled=true;
	}
}

function validaProvinciaConFechas(){
	var conc = document.getElementById("concec");
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var anio = document.getElementById("anio");
	var minI = document.getElementById("minI");
	var minF = document.getElementById("minF");
	
	if(prov.value=="-1"){
		tipo.disabled=false;
		est.disabled=false;
		horaI.disabled=false;
		horaF.disabled=false;
		minI.disabled=false;
		minF.disabled=false;
		conc.disabled= false;
		anio.disabled= false;
	}else{
		tipo.disabled=true;
		est.disabled=true;
		horaI.disabled=true;
		horaF.disabled=true;
		minI.disabled=true;
		minF.disabled=true;
		conc.disabled= true;
		anio.disabled= true;
	}
}

function validaProvinciaConFechasP(){
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var minI = document.getElementById("minI");
	var minF = document.getElementById("minF");
	
	if(prov.value=="-1"){
		tipo.disabled=false;
		est.disabled=false;
		horaI.disabled=false;
		horaF.disabled=false;
		minI.disabled=false;
		minF.disabled=false;
	}else{
		tipo.disabled=true;
		est.disabled=true;
		horaI.disabled=true;
		horaF.disabled=true;
		minI.disabled=true;
		minF.disabled=true;
	}
}

function validaEstacionConTipoIncidente(){
	var conc = document.getElementById("concec");
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var anio = document.getElementById("anio");
	var minI = document.getElementById("minI");
	var minF = document.getElementById("minF");
	
	if(est.value=="-1" && tipo.value=="-1"){
		prov.disabled=false;
		horaI.disabled=false;
		horaF.disabled=false;
		minI.disabled=false;
		minF.disabled=false;
		conc.disabled= false;
		anio.disabled= false;
	}else{
		prov.disabled=true;
		horaI.disabled=true;
		horaF.disabled=true;
		minI.disabled=true;
		minF.disabled=true;
		conc.disabled= true;
		anio.disabled= true;
	}
}

function validaEstacionConTipoIncidenteP(){
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var minI = document.getElementById("minI");
	var minF = document.getElementById("minF");
	
	if(est.value=="-1" && tipo.value=="-1"){
		prov.disabled=false;
		horaI.disabled=false;
		horaF.disabled=false;
		minI.disabled=false;
		minF.disabled=false;
	}else{
		prov.disabled=true;
		horaI.disabled=true;
		horaF.disabled=true;
		minI.disabled=true;
		minF.disabled=true;
	}
}

function validaHorasInicialConHoraFinal(){
	var conc = document.getElementById("concec");
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var anio = document.getElementById("anio");
	
	if(horaI.value!="-1" || horaF.value!="-1"){
		prov.disabled=true;
		est.disabled=true;
		tipo.disabled=true;
		conc.disabled= true;
		anio.disabled= true;
	}else{
		prov.disabled=false;
		est.disabled=false;
		tipo.disabled=false;
		conc.disabled= false;
		anio.disabled= false;
	}
}

function validaHorasInicialConHoraFinalP(){
	var horaI = document.getElementById("horaI");
	var horaF = document.getElementById("horaF");
	var est = document.getElementById("estacion");
	var tipo = document.getElementById("tipoIncidente");
	var prov = document.getElementById("Provincia");
	var minI = document.getElementById("minI");
	var minF = document.getElementById("minF");
	
	if(horaI.value!="-1" || horaF.value!="-1"){
		prov.disabled=true;
		est.disabled=true;
		tipo.disabled=true;
	}else{
		prov.disabled=false;
		est.disabled=false;
		tipo.disabled=false;
	}
}

function validaBusquedaFechas(formulario){	
	if(!validaFechas()){
		return false;
	}	
	form = document.getElementById(formulario);		
	form.submit();
}

function validaBusquedaFechasProvincia(formulario){
	if(!validaFechas()){
		return false;
	}	
	if(!validaProvincia()){
		return false;
	}
	form = document.getElementById(formulario);		
	form.submit()

} 
 

function validaBusquedaFechasEstacion(formulario){
	if(!validaFechas()){
		return false;
	}	
	if(!validaEstacion()){
		return false;
	} 
	form = document.getElementById(formulario);		
	form.submit()

}


function validaBusquedaEstacionTipo(formulario){
	if(!validaFechas()){
		return false;
	}	
	if(!validaEstacion()){
		return false;
	} 
	if(!validaIncidente()){
		return false;
	} 
	form = document.getElementById(formulario);		
	form.submit()

}


function validaBusquedaFechasTipo(formulario){
	if(!validaFechas()){
		return false;
	}	
	
	if(!validaIncidente()){
		return false;
	} 
	form = document.getElementById(formulario);		
	form.submit()

}


function validaBusquedaFechaHoras(formulario){
	if(!validaFechas()){
		return false;
	}	
	if(!validaHoras()){
		return false;
	} 
	form = document.getElementById(formulario);		
	form.submit()
}

function validaBusquedaFechaHorasTipoIncidente(formulario){
	if(!validaFechas()){
		return false;
	}	
	if(!validaHoras()){
		return false;
	} 
	
	if(!validaIncidente()){
		return false;
	}
	form = document.getElementById(formulario);		
	form.submit()
}

function validaBusquedaConsecutivo(formulario){
	var c = document.getElementById("concec");
	

	if(c.value==""){
		alert("Debe seleccionar un consecutivo");
		return false;
	}
	
	form = document.getElementById(formulario);		
	form.submit()

}




function validaBusquedaEE(form){
	if(!validaFechas()){
		return false;
	}
	
	
	
	form= document.getElementById(form);
	
	
	
	form.submit();
	
}


function validaBusquedaRS(form){
	if(!validaFechas()){
		return false;
	}
	if(!validaEstacion()){
		return false;
	}
	
	
	form= document.getElementById(form);
	
	
	
	form.submit();
	
}