$(function() {
    $('.j_loadstate').change(function() {
        var uf = $('.j_loadstate');
        var city = $('.j_loadcity');

        city.attr('disabled', 'true');
        uf.attr('disabled', 'true');
		
        city.html('<option value=""> Carregando cidades... </option>');

        $.post('_cdn/ajax/city.php', {usuario_estado: $(this).val()}, function(cityes) {
            city.html(cityes).removeAttr('disabled');
            uf.removeAttr('disabled');
        });
    });
    
    $('.j_loadcat').change(function() {
        console.log('categoria');
        var cat = $('.j_loadcat');
        var subcat = $('.j_loadsubcat');

        subcat.attr('disabled', 'true');
        cat.attr('disabled', 'true');
		
        subcat.html('<option value=""> Carregando subcategorias... </option>');

        $.post('_cdn/ajax/subcategories.php', {categoria: $(this).val()}, function(subcategories) {
            subcat.html(subcategories).removeAttr('disabled');
            cat.removeAttr('disabled');
        });
    });
});