// Fonctions de mise en page avec lib Mootools


window.addEvent('domready', function() {

	

	if ($('intro_contenu_lien'))
	{

		
		var ancre_presente = window.location.href.test('#');
		var url = window.location.href;
		
		// recup de l'index a utiliser
		 var re = new RegExp('#');
		 var m = re.exec(url);
 
		var toggles = $$('.togglers');
		var content = $$('.elements');
		var item_aff = 0; 
 

		 if (m != null) 
		 {
			var longeur_chaine = url.length;
			 item_aff = parseInt(url.substring(m.index+1, m.index+2));

			 if (isNaN(item_aff))
			 {
				 item_aff = 1;
			 }
			 
		
		 }
		 else
		 {
			if (ancre_presente)
				item_aff = 1;				 
		 }
		 
		var AccordionObject = new Accordion(toggles, content, {show: item_aff} );
	}
	
	if ($('slides'))
	{		
	
		// set up the instance
		var slideshow = new SlideShow('slides',{
			delay: 7000,
			duration: 400,
			transition: 'fadeThroughBackground',
			autoplay: true
		});
		
		var manualPaused = false;

		// add play / pause elements are hovered
		var hoverEvents = {
			mouseenter: function(){ slideshow.pause(); },
			mouseleave: function(){
				if (!manualPaused) 
				{
					manualPaused = false;
					slideshow.play();
					
				}
			}
		};
		
		slideshow.element.addEvents($merge(hoverEvents,{
			// can send transition and duration information to show methods
			click: function() { slideshow.pause(); }
		}));

	}	



});


