var InfoDev = {
   /*
    *
    * Dépendences : Mootools 1.2
    * Auteur : Steven TITREN   -   stitren@ekinoxe.fr
    *
    * Ce fichier est la propriété de la société Ekinoxe ORIGIN - www.ekinoxe.fr
    * Ce fichier n'est en aucun cas libre de droit, vous n'avez pas l'autorisation de 
    * le diffuser ou de le réutiliser dans un projet exterieur.
    *
    */
    'auteur'      : 'Steven Titren',
    'email_pro'   : 'stitren@ekinoxe.fr',
    'email_perso' : 'contact@steven-titren.com' 
}

Element.implement({

 fadeTo : function( amount, whenFinished, duration ) {
   if(typeof whenFinished != 'function') {
	 whenFinished = function() {}   
   }
   this.setStyle('visibility','visible');
   this.effect('opacity', {
      transition : new Fx.Transition(Fx.Transitions.Quad.easeOut, 6).easeOut 
    , duration : ( (duration!=null && duration>0) ? duration : 500 )
    , onComplete : function() { 
	    if(amount==0) this.element.setStyle('visibility','hidden');
	    this.whenFinished.bind(this.element)();
	  }.bind({whenFinished:whenFinished,element:this})
   }).start(this.getOpacity(),amount);
   return this;
 }
		
});


var actu = {
	/** config **/
		divActu: 'actualite',
		divActuContenu : '#actualite div.scroll',
		image1: 'images/actualite_marron.gif',
		image2:'images/actualite_noir.gif',
	/** **/
	
	isOpen:false,
	myFx:null,
	divWith:400,
	
	init:function(){
		actu.divWith = $$(actu.divActuContenu)[0].getStyle('width');
		$(actu.divActu).addEvent('click', function(){
			actu.toggle();
		});
		$(actu.divActu).setStyle('cursor', 'pointer');
		
		actu.setFx();
	},
	
	toggle:function(){
		if(actu.isOpen){
			actu.hide();
		}
		else{
			actu.show();
		}
	},
	
	hide:function(){		
		actu.myFx.start({
			'0':{
				'width':[actu.divWith, 0],
				'opacity': [1,0]
			}
		});

		setTimeout(function(){ actu.changeFade(1) }, 400);
		actu.isOpen = false;
	},
	
	show:function(){
		actu.changeFade(2);
		actu.myFx.start({
			'0':{
				'width':[0, actu.divWith],
				'opacity': [0,0.9]
			}
		});

		actu.isOpen = true;
	},
	
	setFx:function(){
		actu.myFx = new Fx.Elements($$(actu.divActuContenu), {
			duration :800,
			unit:'px',
			transition:Fx.Transitions.Quad.easeInOut
		}).set({
			'0':{
				'width': 0,
				'opacity': 0
			}
		});
	},
	
	changeFade:function(numImage){
		var image = (numImage==1) ? actu.image1 : actu.image2
		
		$$('#' + actu.divActu + ' img ')[0].fadeTo(0, function(){
			$$('#' + actu.divActu + ' img ')[0].set('src', image).fadeTo(1);
		}, 200);
	}
}