$(".form_categorie select").change(function() {
    
    var this_select = $(this)
    var cat_parent = $(this).val();
    
    if(cat_parent == 0){
        $(this).next("div").html("");
    }else{
        
        $.get('/recherche/categorie_ajax/', {
			cat_parent: cat_parent
		}, function(json){  
			//si la requête s'est bien déroulée  
			if (json) { 
				//On interpète le json 
                
                json = eval(json);
                
				if(json.length != 0 ){
    				var html = "";
    				html = "<label>\
                    Sous-catégories :\
            		</label>\
            		<select name='categorie[]'>\
            			<option value='0'>Toutes les sous-catégories</option>";
    				for(i = 0 ; i < json.length ; i++){
    				    html += "<option value='"+json[i][0]+"'>"+json[i][1]+"</option>";
    				}				
    				html += "</select>\
            		<div>\
            		</div>";
            		            						            		
    	    		//$(this).attr('disabled', 'disabled');
                    this_select.next("div").html(html);                                                    
            		$.getScript("/medias/js/form_categories.js",function(){})
            		
                }else{
                    this_select.next("div").html("");
                }
			}else{  
			}
		});
    }
});
