$(document).ready(function() {
	$("#navigation ul").hide();
	
	var matches = $("#navigation a").filter(function () {
		return document.location.href.indexOf($(this).attr('href')) >= 0;
	});
	matches.addClass('current');
	
	$("#navigation a").each(function() {
		if($(this).next()[0] && $(this).next()[0].tagName == "UL") {
			$(this).append('<span class="slide"></span>');
		}
	});
		
	$("#navigation a").click(function(e) {
		if($(this).next()[0].tagName == "UL") {
			e.preventDefault();
			$(this).children().toggleClass('opened');
			$(this).next().slideToggle('fast');
		}
	});
	
	matches.parents("ul").show();
	$("#navigation li:has(a.current)>a span").toggleClass('opened')
});
