 $(document).ready(function() {
	if ($(".dropdown") != null) {
		var doc = document.location.href.split("/");
		if (doc.length > 4 && doc[4].match("^region-")) {
			$(".dropdown.reg dt a span").html($(".dropdown.reg dd ul li a").filter(function(){
				return $(this).attr('href').match(doc[4])
			}).html());
		}
		if (doc.length > 5 && doc[5].match("^departement-")) {
			$(".dropdown.dept dt a span").html($(".dropdown.dept dd ul li a").filter(function(){
				return $(this).attr('href').match(doc[5])
			}).html());
		}
		$(".dropdown.reg dt a").click(function(){
			$(".dropdown.reg dd ul").toggle();
		});
		
		$(".dropdown.reg dd ul li a").click(function(){
			var text = $(this).html();
			$(".dropdown.reg dt a span").html(text);
			$(".dropdown.reg dd ul").hide();
		});
		
		$(".dropdown.dept dt a").click(function(){
			$(".dropdown.dept dd ul").toggle();
		});
		
		$(".dropdown.dept dd ul li a").click(function(){
			var text = $(this).html();
			$(".dropdown.dept dt a span").html(text);
			$(".dropdown.dept dd ul").hide();
		});
		
		$(document).bind('click', function(e){
			var $clicked = $(e.target);
			if (!$clicked.parents().hasClass("dropdown")) 
				$(".dropdown dd ul").hide();
		});
	}
});