window.addEvent('domready',function() {
	
	
// Champ Password----------------------------------------------
// Champ Password----------------------------------------------

// Scrollbar----------------------------------------------


function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	//console.log("content.getSize().scrollSize.y="+content.getSize().scrollSize.y);
	//console.log("content.getSize().size.y="+content.getSize().size.y);
	var steps = (horizontal?(content.getSize().scrollSize.x - content.getSize().size.x):(content.getSize().scrollSize.y - content.getSize().size.y))
	var slider = new Slider(scrollbar, handle, {	
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
onChange: function(step){
	// Scrolls the content element in x or y direction.
	var x = (horizontal?step:0);
	var y = (horizontal?0:step);
	content.scrollTo(x,y);
	}
	}).set(0);
	
if( !(ignoreMouse) ){
// Scroll the content element when the mousewheel is used within the 
// content or the scrollbar element.
$$(content, scrollbar).addEvent('mousewheel', function(e){	
e = new Event(e).stop();
var step = slider.step - e.wheel * 77;	
slider.set(step);					
});
}
// Stops the handle dragging process when the mouse leaves the document body.
$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}
 
window.addEvent('domready', function(){				
// -- first example, vertical scrollbar --
// makeScrollbar( $('articles'), $('scrollbar1'), $('handle1') );

if ($defined($('partenaires'))) {				
	$('partenaires').setStyle('overflow', 'hidden');
	makeScrollbar( $('partenaires'), $('scrollbar-partenaires'), $('handle-partenaires') );
};

if ($defined($('articles'))) {				
	$('articles').setStyle('overflow', 'hidden');
	makeScrollbar( $('articles'), $('scrollbar1'), $('handle1') );
};

if ($defined($('testimoniaux'))) {	
	$('testimoniaux').setStyle('overflow', 'hidden');
	makeScrollbar( $('testimoniaux'), $('scrollbar-partenaires'), $('handle-partenaires') );
};


// -- second example, horizontal scrollbar --
// makeScrollbar( $('content2'), $('scrollbar2'), $('handle2'), true );
// // -- third example, horizontal and vertical scrollbars
// makeScrollbar( $('content3'), $('scrollbar3'), $('handle3'), false );
// makeScrollbar( $('content3'), $('scrollbar4'), $('handle4'), true, true );	
});
// Scrollbar----------------------------------------------


// NewsTicker----------------------------------------------
var Ticker = new Class({
	setOptions: function(options) {
		this.options = Object.extend({
			speed: 1000,
			delay: 5000,
			direction: 'vertical',
			onComplete: Class.empty,
			onStart: Class.empty
		}, options || {});
	},
	initialize: function(el,options){
		this.setOptions(options);
		this.el = $(el);
		this.items = this.el.getElements('li');
		var w = 0;
		var h = 0;
		if(this.options.direction.toLowerCase()=='horizontal') {
			h = this.el.getSize().size.y;
			this.items.each(function(li,index) {
				w += li.getSize().size.x;
			});
		} else {
			w = this.el.getSize().size.x;
			this.items.each(function(li,index) {
				h += li.getSize().size.y;
			});
		}
		this.el.setStyles({
			position: 'absolute',
			top: 0,
			left: 0,
			width: w,
			height: h
		});
		this.fx = new Fx.Styles(this.el,{duration:this.options.speed,onComplete:function() {
			var i = (this.current==0)?this.items.length:this.current;
			this.items[i-1].injectInside(this.el);
			this.el.setStyles({
				left:0,
				top:0
			});
		}.bind(this)});
		this.current = 0;
		this.next();
	},
	next: function() {
		this.current++;
		if (this.current >= this.items.length) this.current = 0;
		var pos = this.items[this.current];
		this.fx.start({
			top: -pos.offsetTop,
			left: -pos.offsetLeft
		});
		this.next.bind(this).delay(this.options.delay+this.options.speed);
	}
});

// var hor = new Ticker('TickerHorizontal',{speed:500,delay:1000,direction:'horizontal'});
if ($defined($('NewsVertical'))) {				
var vert = new Ticker('TickerVertical',{speed:1000,delay:8000,direction:'vertical'});
};

// NewsTicker----------------------------------------------
















});//onDomReady
