$(function() {
	$('#annuaire .subSection').hide();
	
	var current = $('#annuaire a').filter(function() { 
		catFilter = new RegExp('cat='+$(this).attr('id').replace('a','')+'$', 'i');
		return catFilter.test(location.search); 
	});
	if (current.size()) {
		current.addClass('selected');
		current.parents('div.section').addClass('selected').children('h1').addClass('selected');
		current.parents('ul').show();
	}

	$('#annuaire h1:not(.selected)').click(function() {
		if ($(this).hasClass('selected')) {
			return false;
			
		} else {			
			var children = $(this).next('ul.subSection');
			if (children.size()) {
				if (children.css('display') == 'none') {
					$('#annuaire .section:not(.selected) .subSection:visible').slideUp();
				}
				children.slideToggle();
				return false;
			}
			
		}		
	});
});
