$(function() {
	$('.togglable .header').each(function(index) {
			$(this).click(function() {
				$(this).parent().children('.panel').slideToggle();
				$(this).parent().toggleClass('opened');
			})
			if ($(this).parent().hasClass('panel') && $(this).parent().parent().hasClass('togglable')) {
				var dest = $(this).parent().parent();
				$(this).detach();
				dest.prepend($(this));
			}
			if (0==document.location.hash.indexOf('#'+$(this).children('a[name]').attr('name'))) {
				$(this).parent().toggleClass('opened');
			} else {
				$(this).parent().children('.panel').css('display', 'none');
			}
		}
	);
});
