$(document).ready(function(){
	var voletsState = $.readCookie('voletsState') || false;
	// ferme les volets fermé
	$('#volets .ulvolets li').each(function(){
		// voletsState == false on ferme sauf le volet actif
		if (voletsState == false || ($(this).attr('id') != '' && $(this).attr('id') != voletsState)) {
			$(this).children('div.volet_contentWrapper').css('width','0px');
		} else if ($(this).attr('id') == voletsState) {
			$(this).children('div.volet_handle').addClass('selected');
		}
	})
	
	$('#volets .volet_handle').click(function(e) {
		var handle = $(e.target);
		var content = $(this).prev('.volet_contentWrapper');
		// déjà visible, on referme
		if (content.css('width') == '175px') {
			content.animate({width:'0px'},'slow');
			$.setCookie('voletsState',false,{duration:2});
			$(this).removeClass('selected');
		} else {
			$(this).addClass('selected');
			// Un volet à refermer ?
			$('#volets .ulvolets li div.volet_contentWrapper').each(function(){
				if ($(this).css('width') == '175px') {
					$(this).next().removeClass('selected');
					$(this).animate({width:'0px'},'slow');
				}
			});
			content.animate({width:'175px'},'slow');
			$.setCookie('voletsState',handle.parent('li').attr('id'),{duration:2});
		}
	});
});
