/*var SlideNews = new Class({
	_initialized: false,
	_divbg : $('nouvellebg'),
	_divbox : $('nouvellebox'),
	_divbtflechedroit: $('divbtflechedroit'),
	_divbtflechegauche: $('divbtflechegauche'),
	_currentID: 0,
	_newscount: 0,
	//_FXTransition: Fx.Transitions.linear,
	_FXTransition: Fx.Transitions.Expo.easeInOut,
	//_FXTransition: Fx.Transitions.Bounce.easeOut,
	//_FXTransition: Fx.Transitions.Elastic.easeOut,

	_timerFX: 2000,
	_FX : null,
	
	Initialize: function(){
		if(!this._initialized){
			this._newscount = this._divbox.getElementsByTagName("div").length;
			this._divbtflechegauche.setStyle('display', 'none');
			this._divbtflechedroit.setStyle('display', 'block');
			
			this._initialized = true;
		}
	},
	
	DoSlide: function(direction){
		if(direction == 'left' && this._currentID < this._newscount-1){
			this._currentID++;
			this._divbtflechegauche.setStyle('display', 'block');
		}else if(direction == 'right' && this._currentID > 0){
			this._currentID--;
			this._divbtflechedroit.setStyle('display', 'block');
		}
		
		if(this._currentID == this._newscount-1){
			this._divbtflechedroit.setStyle('display', 'none');
		}
		
		if(this._currentID == 0){
			this._divbtflechegauche.setStyle('display', 'none');
		}
		
		if(this._FX){this._FX.cancel();}
		this._FX = new Fx.Morph(this._divbox,
											{
												transition: this._FXTransition,
												duration: this._timerFX
											}
										).start(
												{
													'left': -(this._currentID * (parseInt(this._divbox.getStyle('width')) / this._newscount))
												}
											   );
	}
});*/

var SlideNews = new Class({
	_initialized: false,
	_divbox : $('nouvellebox'),
	_divbtflechedroit: $('divbtflechedroit'),
	_divbtflechegauche: $('divbtflechegauche'),
	_currentID: 0,
	_newscount: 0,
	_loop: false,
	_timer: 10000,
	_FX : [],
	
	Initialize: function(){
		if(!this._initialized){
			this._newscount = this._divbox.getElementsByTagName("div").length;
			
			for(var x = 0; x < this._newscount; x++){
				this._FX[x] = $(this._divbox.getElementsByTagName("div")[x].id);
				this._FX[x].set('tween', {duration: '1000'});

				//hide other than first
				if(x > 0){
					this._FX[x].fade('hide');
				}
			}
			this._divbtflechegauche.setStyle('display', 'none');
			this._divbtflechedroit.setStyle('display', 'block');
			
			this._initialized = true;
		}
	},
	
	Start: function(){
		if(this._initialized){
			this._loop = true;
			this.DoFade.periodical(this._timer, this, 'left');
		}
	},
	
	DoFade: function(direction){
		if(this._initialized){
			if(!this._loop){
				//when user click
				if(direction == 'left' && this._currentID < this._newscount-1){
					this._FX[this._currentID].fade('out');
					this._currentID++;
					this._FX[this._currentID].fade('in');
					//this._divbtflechegauche.setStyle('display', 'block');
				}else if(direction == 'right' && this._currentID > 0){
					this._FX[this._currentID].fade('out');
					this._currentID--;
					this._FX[this._currentID].fade('in');
					//this._divbtflechedroit.setStyle('display', 'block');
				}
			}else{
				//on loop
				this._FX[this._currentID].fade('out');
				if(this._currentID == this._newscount-1){ this._currentID = -1; }
				this._currentID++;
				this._FX[this._currentID].fade('in');
			}
			
			if(this._currentID != 0){ // not on first
				this._divbtflechegauche.setStyle('display', 'block');
			}
			if(this._currentID != this._newscount-1){ // not on last
				this._divbtflechedroit.setStyle('display', 'block');
			}			
			if(this._currentID == this._newscount-1){ //on last
				this._divbtflechedroit.setStyle('display', 'none');
			}			
			if(this._currentID == 0){ // on first
				this._divbtflechegauche.setStyle('display', 'none');
			}
		}
	}
});
