var sl_home;
function init_home(){
	
	var homed = document.getElementById('bande_home');
	var divs = homed.getElementsByTagName('div');
	var arr_news = new Array();
	
	for(var i=0; i<divs.length; i++){
		if(divs[i].className == "une_info"){
				var tt = divs[i].cloneNode(true)
				arr_news.push(divs[i]);
		}
	}
	
	homed.parentNode.removeChild(homed);
	sl_home = new sl_home(document.getElementById('home_mea'),arr_news);
}

function sl_home(containerDiv, arr){
	this.nbre = arr.length;
	this.arr = arr;
	this.cur = 0;
	this.curaff = 0;
	this.arr_tw = new Array();
	this.transition = 550;
	this.decal=100;
	this.timeouts = new Array();
	this.inerv;
	this.inerval = 5000;
	containerDiv.style.overflow='hidden';
	containerDiv.style.position='relative';
	
	
	
	
	
	for(var i=0; i<arr.length; i++){
		containerDiv.appendChild(arr[i]);
		this.arr[i].style.position = 'absolute';
		this.arr[i].style.top = '0px';
		this.arr[i].style.zIndex = i;
		pos = (i == this.cur)?0:-600;
		this.arr_tw[i] = new Tween(arr[i], {'left':pos});	
	}
	
	this.onmov = function(id){
		this.pause();	
		this.change_ima(id);
	}
	
	this.onmou = function(){
		this.play();	
	}
	
	this.change_ima = function(id){
		
		if(id == this.cur)return;
		var div = this.arr[id];
		var int = 0;
		var laclass = this;
		this.curaff = this.cur;
		if(id>this.cur){			
			for(var y=this.cur+1; y<=id; y++){
				setTimeout(function(){laclass.bouge_ima_plus()},this.decal*int);
				int ++;
			}			
		}else{
			for(var y=this.cur; y>id; y--){				
				setTimeout(function(){laclass.bouge_ima_moins()},this.decal*int);
				int ++;
			}
		}
		this.cur = id;
		this.set_liens();
	}
	
	
	this.cache_ima = function(id){}
	
	this.bouge_ima_plus = function(pos){
		this.curaff++;
		this.arr_tw[this.curaff].moveTo({'left':0}, this.transition);
	}
	
	this.bouge_ima_moins = function(pos){		
		this.arr_tw[this.curaff].moveTo({'left':-600}, this.transition);	
		this.curaff--;	
	}
	this.pause = function(){
		clearInterval(this.interv);
	}
	this.play = function(){
		var laclass = this;
		this.interv	= setTimeout(function(){laclass.nextIma()},laclass.inerval);
	}
	
	this.nextIma = function(){
		var laclass = this;
		var im = this.cur+1;
		if(im >= this.nbre){
			im = 0;	
		}
		this.change_ima(im);
		this.interv	= setTimeout(function(){laclass.nextIma()}, laclass.inerval);
	}
	
	this.set_liens = function(){
		
		
		
		var liens = document.getElementById('bande_ronds').getElementsByTagName('div');
		
		for(var i=0; i<liens.length;i++){
			var li = liens[i];
			var cn = li.className;
			var typ = li.className.substr(cn.length-1,1);
			var bgi = 'hp_bout_'+((i == this.cur)?'h_':'')+typ+'.png';
			li.style.backgroundImage = 'url('+base+'graph/home/'+bgi+')';
		}
	}
	this.set_liens();
	this.play();
	
}
