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

	if ($('slides'))
	{		
	
		// set up the instance
		var slideshow = new SlideShow('slides',{
			delay: 5000,
			duration: 600,
			transition: 'fade',
			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(); }
		}));
		

		

	}
	
	
	if ($('slide_formule'))
	{		
	
		// set up the instance
		var slideshow = new SlideShow('slide_formule',{
			delay: 5000,
			duration: 600,
			transition: 'fade',
			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(); }
		}));
		
		// navigation	   
	   /* var slideLabels = $$('.typeLI');
	   slideLabels.each(function(el, index){
		   el.store('slide', slideshow.slides[index]);
		   
		   el.addEvent('mouseenter',function() {
			manualPaused = true;
			slideshow.pause();
		   	slideshow.show(el.retrieve('slide'));

		   });	
		   
	   }); */  		
		

	}	
	
	if ($('encartDestination'))
	{		
	
		// set up the instance
		var slideshow = new SlideShow('encartDestination',{
			delay: 7000,
			duration: 800,
			transition: 'pushUp',
			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(); }
		}));

	}	
	
	if ($('diaporama_sejour'))
	{		
	affImage(1);
	}
	
	
	if ($('bloc_slide_tags'))
	{
		//var myTicker = new mooTicker('TickerNews',{interval:15000});
		mySlideShow = new SlideShow('slides_tags',{
			delay: 7000,
			autoplay: true,
			transition:'pushLeft',
			duration:1500
		});		

		var manualPaused = false;

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

		/* boutons d'actions */
	   $('left_event').addEvents({
			click: function(){
				manualPaused = true;
				mySlideShow.showPrevious({transition: 'pushRight', duration: '500'})
			}
		});
	   
	   $('right_event').addEvents({
			click: function(){
				manualPaused = true;
				mySlideShow.showNext({transition: 'pushLeft', duration: '500'})
			}
		});	
		
	}		
	
	
	if ($('slide_form'))
	{
	
		var myContactForm = new Fx.Slide('slide_form', 
							{wait: false, 
							 onComplete: function(request){ 
							 var open = request.getStyle('margin-top').toInt();
							 if(open >= 0) new Fx.Scroll(window).toElement('slide_form');
							}
							 
							});
		
		myContactForm.hide();
		var etatSlide = 0;	

		$('bloc_contact').addEvents({
			'click' : function(e){
				e = new Event(e);
				myContactForm.toggle();
				etatSlide = 1;
				e.stop()
			}

		});	
	
	
	}
	
	
	if ($('aff_form'))
	{	
	
		$('aff_form').addEvent('click', function(e){
			e.stop();
			$('aff_form').setStyle('display', 'none');
			$('form_preinscription').setStyle('display', 'block');
		});		
	
	

		
		var myAccordion = new Fx.Accordion($$('.boutonform'), $$('.pageform'));	
		
	}
	
	
	if ($('form_destinations'))
	{		
	

		/* for keeping track of what's "open" */
		var activeClass = 'dropdown-active', showingDropdown, showingMenu, showingParent;
		/* hides the current menu */
		var hideMenu = function() {
			if(showingDropdown) {
				showingDropdown.removeClass(activeClass);
				showingMenu.setStyle('display','none');
			}
		};
		/* recurse through dropdown menus */
		$$('.dropdown').each(function(dropdown) {
			/* track elements: menu, parent */
			var menu = dropdown.getNext('div.dropdown-menu'), parent = dropdown.getParent('div');
			/* function that shows THIS menu */
			var showMenu = function() {
				hideMenu();
				showingDropdown = dropdown.addClass('dropdown-active');
				showingMenu = menu.setStyle('display','block');
				showingParent = parent;
			};
			/* function to show menu when clicked */
			dropdown.addEvent('click',function(e) {
				if(e) e.stop();
				showMenu();
			});
			/* function to show menu when someone tabs to the box */
			dropdown.addEvent('focus',function() {
				showMenu();
			});
		});
		/* hide when clicked outside */
		$(document.body).addEvent('click',function(e) {
			if(showingParent && !e.target || !$(e.target).getParents().contains(showingParent)) { 
				hideMenu();
			}
		});

	
	}


});



// fonction js complementaires
function ouvrePage(href) 
{
	document.location.href= href;
}



