News = new Class({
    initialize: function(dateString){
		this.iMax = $$('#newsContent .bloc').length-1;
		this.iCount = this.iMax;
		
		this.formatBloc();
       
    },
	formatBloc: function(){
		$$('#news .bloc').setStyles({opacity:0, position:"absolute"})	
    },
	updateCount: function(){

	    if(this.iCount >= this.iMax)
			this.iCount = 0;
		else
			this.iCount++;

    },
    stopTimer: function(){
        $clear(this.dalay);
    },
    startTimer: function(){
       
		var oldEl = $$('#news .bloc')[this.iCount]
		this.updateCount();
		var newEl =	$$('#news .bloc')[this.iCount]
		
		var effect = new Fx.Morph(oldEl, {duration:500, wait:false,transition: Fx.Transitions.Sine.easeOut});
		effect.start({'opacity' :0})
		
		var effect = new Fx.Morph(newEl, {duration:500, wait:false,transition: Fx.Transitions.Sine.easeOut});
		effect.start({'opacity' :.9})
		
		this.delay = this.startTimer.delay(5000, this);
    },
	start:function(){
		if(this.iMax > 0)
			this.delay = this.startTimer.delay(500, this);
		else 
			$$('#news .bloc').setStyles({opacity:1, position:"absolute"})	
	}
	
});
  


Glossaire = new Class({
    initialize: function(els){		
		this.els = $$(els)
		this.initEls();
    },
	//=====================================
	// parametrage de la liste des elements
	//===================================== 
	initEls: function(){
	
		this.els.each(function(element,index) {  
			var content = element.get('title').split('::');  
			element.store('tip:title', content[0]);  
			element.store('tip:text', content[1]);  
		});  
	
		var tipz = new Tips($$('acronym'),{  
	         className: 'tipz',  
	         fixed: true,  
	         hideDelay: 50,  
	         showDelay: 50  
	     }); 
		 
		 
		tipz.addEvents({  
			'show': function(tip) {  
			tip.fade('in');  
			},  
			'hide': function(tip) {  
			tip.fade('out');  
			}  
		});  
   
    
    }
});


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

	new Glossaire('acronym');
	
	
	
		  
	//===========================================
	// annimation des lien de la colone de gauche
	//===========================================
	var list = $$('#colLeft li');
	list.each(function(el) {
	
		var morph = new Fx.Morph(el,{duration:100, wait:false,transition: Fx.Transitions.Sine.easeInOut});
		el.addEvent('mouseenter', function(){
			morph.start({	'padding-left': "25px" });
		});
	 
		el.addEvent('mouseleave', function(){
			morph.start({	'padding-left':"15px" 	});
		});				
	 
	});	
   	


	/*
	* Annimation des news
	*/
	new News().start();
	
	new SmoothScroll();	   
	
});
