$(document).ready(function(){
	$("#cbTipo").change(function(){
			valor = $(this).val();	
			$("#cbMarca").html('<option value="0" selected="selected">Marca</option>');
			$("#cbMarca").attr("disabled", "disabled");
			$("#cbModelo").html('<option value="0" selected="selected">Modelo</option>');
			$("#cbModelo").attr("disabled", "disabled");	
			$("#cbVersion").html('<option value="0" selected="selected">Versi&oacute;n</option>');
			$("#cbVersion").attr("disabled", "disabled");
			
			$("#cbMarca").removeAttr("disabled");
			
			if(valor!="0"){
				$.post("include/proceso_combos.php",{
					combo:$(this).attr("name"),
					id:$(this).val()
					},function(data){
					$("#cbMarca").html(data);
				})												
			}else{
				$("#cbMarca").attr("disabled", "disabled");
			}			
	})		
	
	$("#cbMarca").change(function(){
			valor = $(this).val();	
			$("#cbModelo").removeAttr("disabled");
			$("#cbVersion").html('<option value="0" selected="selected">Versi&oacute;n</option>');
			$("#cbVersion").attr("disabled", "disabled");
			if(valor!="0"){
				$.post("include/proceso_combos.php",{
					combo:$(this).attr("name"),
					id:$(this).val(),
					tipo:$("#cbTipo").val()
					},function(data){
					$("#cbModelo").html(data);
				})												
			}else{
				$("#cbModelo").attr("disabled", "disabled");
			}			
	})	
	
	$("#cbModelo").change(function(){
			valor = $(this).val();	
			$("#cbVersion").removeAttr("disabled");
			
			if(valor!="0"){
				$.post("include/proceso_combos.php",{
					combo:$(this).attr("name"),
					id:$(this).val(),
					tipo:$("#cbTipo").val() 
					},function(data){
					$("#cbVersion").html(data);
				})												
			}else{
				$("#cbVersion").attr("disabled", "disabled");
			}			
	})	

	$("#frmCombos").click(function(e){
	   e.preventDefault();
		if($("#cbTipo").val()=="0"){
			alert("debe seleccionar al menos el tipo de vehiculo");
		}
		else{
			$("#frmBusFicha").submit()
		}

	})				
})
