window.addEvent('domready', function()
{
	var mainPath = "fileadmin/templates/";
	//var mainPath = "";
	/* SUCKERFISH MENU */
	if(Browser.Engine.trident && Browser.Engine.version < 5)
	{
		//Suckerfish Alternative for IE, using MOOTOOLS.
		$$('#menu li').each(function(el, index)
		{
			el.addEvents(
			{
				'mouseenter':function(e)
				{
					this.addClass('over');
				},
				'mouseleave':function(e)
				{
					this.removeClass('over');
				}
			});
		});
	}
	
	if ($('formReserv')) {
		
		MooTools.lang.set('fr-FR', 'Date', {
			months:    ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
			days:      ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
			dateOrder: ['date', 'month', 'year', '/']
		});
		
		MooTools.lang.setLanguage('fr-FR');
		
		new CalendarEightysix('datedeb', 	 { 'format': '%d/%m/%Y', 'theme': 'default grey', 'minDate': 'tomorrow','startMonday': true,'offsetY': -4 });
		
		new CalendarEightysix('datefin', 	 { 'format': '%d/%m/%Y', 'theme': 'default grey', 'minDate': 'tomorrow','startMonday': true,'offsetY': -4 });
		
	}
	
	/* banner rotator example */	
	if($('accPhotos')) {
		new SlideItMoo({overallContainer: 'accPhotos',
			elementScrolled: 'SlideItMoo_banners_inner',
			thumbsContainer: 'SlideItMoo_banners_items',		
			itemsVisible:4,
			itemWidth: 113,
			itemsSelector: '.banner',
			showControls:0,
			autoSlide: 1500,
			transition: Fx.Transitions.quad,
			duration: 700,
			direction:1});
	}
	
	if($('accPhotosWide')) {
		new SlideItMoo({overallContainer: 'accPhotosWide',
			elementScrolled: 'SlideItMoo_banners_inner',
			thumbsContainer: 'SlideItMoo_banners_items',		
			itemsVisible:8,
			itemWidth: 113,
			itemsSelector: '.banner',
			showControls:0,
			autoSlide: 3000,
			transition: Fx.Transitions.quad,
			duration: 700,
			direction:1});
	}
	
	/* banner rotator example */	
	if($('logos-dynamiques')) {
		new SlideItMoo({overallContainer: 'logos-dyn-outer',
			elementScrolled: 'logos-dyn-inner',
			thumbsContainer: 'logos-dyn-items',		
			itemsVisible:1,
			itemWidth: 85,
			itemsSelector: '.partenaire',
			showControls:0,
			autoSlide: 4000,
			transition: Fx.Transitions.quad,
			duration: 700,
			direction:1});
	}
	
	
	if($('batipaume-galerie-moyen-anime')) {
		new SlideItMoo({overallContainer: 'batipaume-galerie-moyen-anime',
			elementScrolled: 'SlideItMoo_banners_inner-moyen',
			thumbsContainer: 'SlideItMoo_banners-moyen',		
			itemsVisible:3,
			itemWidth: 197,
			itemsSelector: '.bat-gal',
			showControls:0,
			autoSlide: 3000,
			transition: Fx.Transitions.quad,
			duration: 700,
			direction:1});
	}
	
	if($('batipaume-galerie-petit-anime')) {
		new SlideItMoo({overallContainer: 'batipaume-galerie-petit-anime',
			elementScrolled: 'SlideItMoo_banners_inner-petit',
			thumbsContainer: 'SlideItMoo_banners-petit',		
			itemsVisible:3,
			itemWidth: 113,
			itemsSelector: '.bat-gal',
			showControls:0,
			autoSlide: 3000,
			transition: Fx.Transitions.quad,
			duration: 700,
			direction:1});
	}
	
	if($('batipaume-galerie-grand-anime')) {
		new SlideItMoo({overallContainer: 'batipaume-galerie-grand-anime',
			elementScrolled: 'SlideItMoo_banners_inner-grand',
			thumbsContainer: 'SlideItMoo_banners-grand',		
			itemsVisible:2,
			itemWidth: 319,
			itemsSelector: '.bat-gal',
			showControls:0,
			autoSlide: 1500,
			transition: Fx.Transitions.quad,
			duration: 700,
			direction:1});
	}
	
	
	/*

	var testD = function(el, ind)
	{
		var dd = $$('.logo a')[ind];
		if(dd)
		{
			// alert('coucou');
			var mtop = (dd.getSize().y - el.getSize().y) / 2;
			el.setStyle('margin-top',mtop.round());
		}
	};
	
	$$('.logo a img').each(function(el, ind){
		testD(el, ind);
	});
	
	var testF = function(el, ind)
	{
		var dd = $$('#ficheMenuPrinc .item a')[ind];
		if(dd)
		{
			// alert('coucou');
			var mtop = (dd.getSize().y - el.getSize().y) / 2;
			el.setStyle('margin-top',mtop.round());
		}
	};
	
	$$('#ficheMenuPrinc .item a img').each(function(el, ind){
		testF(el, ind);
	});
	
	*/
	
	/*
	if($('actusWrapper'))
	{
		//$$('#actusWrapper .actu .plus a').each(function(el, ind){
		$$('#actusWrapper .actu .plus a').each(function(el, index)
		{
			el.addEvents(
			{
				'click':function(e)
				{
					e.stop();
					Mediabox.open(this.get('href'), this.get('title'), 'width height');
				}
			});
		});
	}
	*/
	
	if($('actus'))
	{
		$('accActus').setStyle('margin-left',18);
		var scroller = new fmcScrollTo({
			slides: $$('#actus .actu'),
			container: $('actus'),
			duration:700
		});
		$$('#elEnCours').set('text',scroller.startIndex +1);
		var steps = $$('#actus .actu').length; 
		var theStep = 0;
		var stepLength = 1;
		var scrollable = true;
		var stepsArray = new Array();
		var el = $('actusNav');
		var navCanMove = true;
		var btns = {
			next:el.getElements('.next')[0],
			prev:el.getElements('.prev')[0]
		};
		$$('#nbTotal').set('text',steps);
		$('accActus').addEvents(
		{
			'mouseenter':function()
			{
				navCanMove=false;
			},
			'mouseleave':function()
			{
				navCanMove=true;
			}
		});
		checkBTNS(scroller.startIndex, steps, stepLength, btns);
		el.getElements('.prev')[0].addEvent('click',function(e)
		{
			if(e) e.stop();
			if(scroller.startIndex != 0 && (scroller.startIndex-stepLength)>=0)
			{
				scroller.scrollToEl(scroller.startIndex-stepLength);
			}else{
				scroller.scrollToEl(0);
			}
			checkBTNS(scroller.startIndex, steps, stepLength, btns);
			$$('#elEnCours').set('text',scroller.startIndex +1);
		});
		el.getElements('.next')[0].addEvent('click',function(e)
		{
			if(e) e.stop();
			if(scroller.startIndex < steps-1 && Math.ceil(scroller.startIndex + stepLength / stepLength) - 1 <= steps)
			{
				scroller.scrollToEl(scroller.startIndex+stepLength);
			}else{
				//alert('Last : '+ scroller.startIndex +' - '+ (stepLength*steps-stepLength));
				scroller.scrollToEl(stepLength*steps-stepLength);
			}
			checkBTNS(scroller.startIndex, steps, stepLength, btns);
			$$('#elEnCours').set('text',scroller.startIndex +1);
		});
		var moveAlone = (function()
		{
			if(scroller.startIndex == steps-1 ) scroller.startIndex = -1;
			if(navCanMove) btns.next.fireEvent('click');
		}).periodical(5000, this);
	}
	
	// Liens Accueil
	/*
	if($('entrer-familles')) {
		$('entrer-familles').addEvents({
			'mouseenter':function(e)
			{
				this.tween('top', -10);
			},
			'mouseleave':function(e)
			{
				this.tween('top', 0);
			}
		});		
	}
	
	if($('entrer-classes')) {
		$('entrer-classes').addEvents({
			'mouseenter':function(e)
			{
				this.tween('top', -10);
			},
			'mouseleave':function(e)
			{
				this.tween('top', 0);
			}
		});		
	}
	*/
	var animFlash = new Swiff(mainPath+"flash/anim-header.swf", { id: 'flash', width:680, height:185, params: { 'wmode': 'transparent','AllowScriptAccess':'always' }, vars: { xmlFile:"http://www.batipaume.com/index.php?id=27" } 	});
	animFlash.inject('headerFlash');
	
	/*
	var myTips = new Tips('.secteurs img', {title:'title'});
	
	*/
});