
window.addEvent('domready', function() {
    /*
     * This updates the filter dropdown boxes whenever the region filter is 
     * changed so that they only show the list of categories that are enabled
     * for that region
     */
    try{ 
        var region_box = $E('#id_experience-region');
        // Update the content of the dropdown boxes when the region changes
        region_box.addEvent('change', function(){
            var industry_box = $E('#id_experience-industry');
            var service_box = $E('#id_experience-service');
            var sector_box = $E('#id_experience-sector');
            
            // Repopulate the industry box
            industry_box.options.length = 0;
            
            for (var i=0; i<industry_options[region_box.value].length; i++){
                industry_box.options[i] = industry_options[region_box.value][i];
            }
            // Make sure the "All" option is selected
            industry_box.options[0].selected = true;
            
            // Repopulate the service box
            service_box.options.length = 0;
            
            for (var i=0; i<service_options[region_box.value].length; i++){
                service_box.options[i] = service_options[region_box.value][i];
            }
            // Make sure the "All" option is selected
            industry_box.options[0].selected = true;
            
            // Repopulate the sector box
            sector_box.options.length = 0;
            
            for (var i=0; i<sector_options[region_box.value].length; i++){
                sector_box.options[i] = sector_options[region_box.value][i];
            }
            // Make sure the "All" option is selected
            industry_box.options[0].selected = true;
        }.bindWithEvent(region_box));
    }catch(err){ } 
});

