function valMarcaModelo(f)
{
	if (f.sMarca.value=="")
	{
		alert("Seleccione una marca");
		f.sMarca.focus();
		return false;
	}
	return true;
}

function valSegmento(f)
{
	if (f.sSegmento.value=="" && f.sCombustible.value=="")
	{
		alert("Debe seleccionar el segmento o el combustible para realizar la búsqueda");
		return false;
	}
	return true;
}

function irA(cmb,paginasize){
  var paginanro = cmb.options[cmb.selectedIndex].value;
  document.forms['fPagAutos'].orden.value = (paginanro-1)*paginasize;
  document.forms['fPagAutos'].submit();
}

function validarBusAdv(f){
	var cont=0;
	
	if(f.sMarca.value!='')
		cont++;

	if(f.sModelo.value!='')
		cont++;

	if(f.sVersion.value!='')
		if(!isText50(f.sVersion) ){
			alert('La versión ingresada es inválida.');
			f.sVersion.focus();
			return false;
		}else{
			if(!cont){
				alert('Para buscar por versión debe seleccionar la marca.');
				f.sMarca.focus();
				return false;
			}
			cont++;
		}

		// valido años
	for( i=0,aniosSeleccionados=0 ; i < document.getElementById('sAnio[]').length ; i++){
		if(document.getElementById('sAnio[]').options[i].selected) aniosSeleccionados++;
	}
	if(aniosSeleccionados>10){
		alert('No puede seleccionar más 10 años');
		return false;
	}
	if(document.getElementById('sAnio[]').value!='')
		cont++;

	if(f.sSegmento.value!='')
		cont++;

	if(f.sCombustible.value!='')
		cont++;

	if(f.sPrecioDesde.value!='' || f.sPrecioHasta.value!=''){
		if(f.sPrecioDesde.value!='' && f.sPrecioHasta.value!=''){
			if( !isPrecio(f.sPrecioDesde) || f.sPrecioDesde.value <1 ){
				alert('El valor ingresado en "Precio Desde" es inválido.');
				f.sPrecioDesde.focus();
				return false;
			}
			if( !isPrecio(f.sPrecioHasta)  || f.sPrecioHasta.value <1 ){
				alert('El valor ingresado en "Precio Hasta", es inválido.');
				f.sPrecioHasta.focus();
				return false;
			}
			if(f.sPrecioHasta.value>f.sPrecioDesde.value*2){
				alert('Ha superado el rango entre los precios, aumente el "Precio Desde" o disminuya el "Precio Hasta".');
				f.sPrecioHasta.focus();
				return false;
			}
			cont++;
		}else{
			alert('Ingrese ambos criterios de búsqueda por precio');
			f.sPrecioDesde.focus();
			return false;
		}
	}

  // valido equipamientos
	for( i=0,equiSeleccionados=0 ; i < document.getElementById('sEquipamientos[]').length ; i++){
		if(document.getElementById('sEquipamientos[]').options[i].selected) equiSeleccionados++;
	}
	if(equiSeleccionados>15){
		alert('No puede seleccionar más de 15 equipamientos');
		return false;
	}

	if(!cont){
		alert('Debe especificar algún dato para la búsqueda');
		return false;
	}

	if(f.sSegmento.value!='' && cont == 1){
		alert('La búsqueda sólo por segmento es muy extensa,\ndebe especificar algún dato para refinarla.');
		return false;
	}
}