$(document).ready( function () { 

	var $_GET = {};
	document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
		function decode(s) {
			return decodeURIComponent(s.split("+").join(" "));
		}
	$_GET[decode(arguments[1])] = decode(arguments[2]);
	});

	if($_GET['deroule']) {
		deroule_manuelle($_GET['deroule']);
	}
	
	//Gestion de déroulement des bloc
	$('.lien_dhtml').click( function() {
		if(!$(this).hasClass('deroule'))
		{
			$('.lien_dhtml').next('div').slideUp('slow');
			$('.lien_dhtml').removeClass('deroule');
			$('.lien_dhtml').children('img.icone_gauche').attr('src','img/template/picto_enroule.gif');
			$('.lien_dhtml').children('img.icone_droite').attr('src','img/bt_info.gif');
			$('.lien_dhtml').nextAll('.cadre_cmd_bottom').addClass('cadre_cmd_bottom_alt');
			$('.lien_dhtml').nextAll('.cadre_cmd_bottom').removeClass('cadre_cmd_bottom');
			
			
			
			$(this).addClass('deroule');
			$(this).children('img.icone_gauche').attr('src','img/template/picto_deroule.gif');
			$(this).children('img.icone_droite').attr('src','img/bt_fermer_gris.gif');
			$(this).nextAll('.cadre_cmd_bottom_alt').addClass('cadre_cmd_bottom');
			$(this).nextAll('.cadre_cmd_bottom_alt').removeClass('cadre_cmd_bottom_alt');
			$(this).next('div').slideDown('slow');
		}else{
			$(this).next('div').slideUp('slow');
			$(this).removeClass('deroule');
			$(this).children('img.icone_gauche').attr('src','img/template/picto_enroule.gif');
			$(this).children('img.icone_droite').attr('src','img/bt_info.gif');
			$(this).nextAll('.cadre_cmd_bottom').addClass('cadre_cmd_bottom_alt');
			$(this).nextAll('.cadre_cmd_bottom').removeClass('cadre_cmd_bottom');
		}
	});
	
});


function deroule_manuelle(id)
{
	var hauteur = $('#'+id).offset().top;
	
    $('html,body').animate({scrollTop: hauteur-10}, 1000);
	$('.lien_dhtml').next('div').slideUp('slow');
	$('.lien_dhtml').removeClass('deroule');
	$('.lien_dhtml').children('img.icone_gauche').attr('src','img/template/picto_enroule.gif');
	$('.lien_dhtml').children('img.icone_droite').attr('src','img/bt_info.gif');
	$('.lien_dhtml').nextAll('.cadre_cmd_bottom').addClass('cadre_cmd_bottom_alt');
	$('.lien_dhtml').nextAll('.cadre_cmd_bottom').removeClass('cadre_cmd_bottom');
	
	
	
	$('#'+id).addClass('deroule');
	$('#'+id).children('img.icone_gauche').attr('src','img/template/picto_deroule.gif');
	$('#'+id).children('img.icone_droite').attr('src','img/bt_fermer_gris.gif');
	$('#'+id).nextAll('.cadre_cmd_bottom_alt').addClass('cadre_cmd_bottom');
	$('#'+id).nextAll('.cadre_cmd_bottom_alt').removeClass('cadre_cmd_bottom_alt');
	$('#'+id).next('div').slideDown('slow');
}