$(document).ready(function() {
	// On retire les commentaires dans les block 'scriptonly'
	$(".scriptonly").each(function(i) {
		html = $(this).html();
		html = html.replace('<!--', '').replace('-->', '');
		$(this).html(html);
	});
	
	$('.menu_document > li > a').click(function() {
		// Cas particulier de redirection
		if ($(this).parent().find('>ul>li').is('.redirect'))
			return true;
		
		if ($(this).parent().find('>ul').is('.on'))
		{
			$(this).parent().find('>ul').animate({ height: 'hide', opacity: 'hide' }, 'slow');
			$(this).parent().find('>ul').removeClass("on");
		}
		else
		{
			$(this).parent().parent().find('li>ul.on').each(function() {
				$(this).animate({ height: 'hide', opacity: 'hide' }, 'slow');
				$(this).removeClass("on");
			});
			$(this).parent().find('>ul').animate({ height: 'show', opacity: 'show' }, 'show');
			$(this).parent().find('>ul').addClass("on");
		}
		
		return false;
	});
	
	$('.menu_document ul li > a').click(function() {
		if ($(this).parent().find('ul').is('.on'))
		{
			$(this).parent().find('ul').animate({ height: 'hide', opacity: 'hide' }, 'slow');
			$(this).parent().find('ul').removeClass("on");
		}
		else
		{
			$(this).parent().parent().find('ul.on').each(function() {
				$(this).animate({ height: 'hide', opacity: 'hide' }, 'slow');
				$(this).removeClass("on");
			});
			$(this).parent().find('ul').animate({ height: 'show', opacity: 'show' }, 'show');
			$(this).parent().find('ul').addClass("on");
		}
		
		return false;
	});
});