// JavaScript Document

$(document).ready(function(){
	$("select").change(function(){
		var combos = new Array();
		combos['cat'] = "subcat";
		// combos['estado'] = "ciudad";		
		posicion = $(this).attr("name");		
		valor = $(this).val()	
		if(posicion == 'cat' && valor==0){
			$("#subcat").html('<option value="0" selected="selected">- Seleccionar -</option>')
			//$("#ciudad").html('<option value="0" selected="selected">----------------</option>')
		}else{		
			$("#"+combos[posicion]).html('<option selected="selected" value="0">Cargando...</option>')
			if(valor!="0" || posicion !='ciudad'){			
				$.post("combos.php",{
									combo:$(this).attr("name"), // Nombre del combo
									id:$(this).val() // Valor seleccionado
									},function(data){
													$("#"+combos[posicion]).html(data);				
													})												
			}
		}
	})		
})
