// Fonctions de mise en page avec lib Mootools

window.addEvent('domready', function() {

	if (document.getElementById('TickerVertical'))
	{
		var Ticker = new Class({
			setOptions: function(options) {
				this.options = Object.extend({
					speed: 1000,
					delay: 5000,
					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;
				this.items.each(function(li,index) {
					w += li.getSize().size.x
				});
				this.el.setStyles({
					position: 'absolute',
					top: 0,
					left: 0,
					width: w
				});
				this.periodical = 
				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.setStyle('left',0);
					
	
				}.bind(this)});
				this.current = 0;
				this.next();
			},
			next: function() {
				this.current++;
				if (this.current >= this.items.length) this.current = 0;
				this.fx.start({
					top: this.items[this.current].offsetTop,
					left: -this.items[this.current].offsetLeft
				});
				this.next.bind(this).delay(this.options.delay);
			}
		});
		
		var vert = new Ticker('TickerVertical',{speed:1000,delay:10000,direction:'horizontal'});
	
	}
	
	
	if (document.getElementById('bloc_suite'))
	{	

			var list = $$('#contenu .lire_suite_bloc');
			var headings = $$('#contenu .lire_suite_lien');
			var spans = new Array();	
			var collapsibles = new Array();
			
			headings.each( function(heading, i) {

				var collapsible = new Fx.Style(list[i], 'height',{duration: 500});
				
				collapsibles[i] = collapsible;
				
				heading.onclick = function(){
					
				  var span = $E('span', heading);
			
				  if(list[i].getStyle('height').toInt() > 70){
					//hide
				  	collapsible.start(70);
					span.setHTML('Lire la suite');
				  }else{
					//show
					collapsible.start(c1Height);
					span.setHTML('Replier');
				  }

				   return false;
				}
				
				//collapsible.setStyle(’display','block’);
				var c1Height = list[i].getSize().scrollSize.y;

				
			});
			


	
	
	}



});