var z_mea;
function init_mea(){
	z_mea = new mea();
}

function mea(){
	this.cur = 0;
	this.tmps = 4000;
	
	if(!document.getElementById('mea_cont'))return;
	var div_mea = document.getElementById('mea_cont');
	
	var nb_n = div_mea.getElementsByTagName('div');
	this.wid = parseInt(nb_n[0].style.width);
	this.nbre = (nb_n.length/2);
	var dpts = document.getElementById('pts');
	this.tw = new Tween(div_mea,{'left':0});
	
	var laClass =this;
	
	this.liens = new Array();
	for(var i=0; i<this.nbre; i++){
			var a = document.createElement('a');
			a.nbr = i;
			a.onclick = function(){
				laClass.mvt(this.nbr);
			}
			dpts.appendChild(a);
			this.liens.push(a);
	}
	
	this.mvt = function(p){
		this.cur = p;
		clearInterval(this.interv);
		var l= -this.wid*p;
		this.tw.moveTo({'left':l},450);
		this.verifLiens();
		this.setInterv();
	}
	
	this.verifLiens = function(){
		for(var t=0; t<this.liens.length; t++){
			this.liens[t].className = (this.liens[t].nbr==this.cur)?'sel':'';	
		}
	}
	
	
	
	this.plus = function(){
		this.cur ++;
		if(this.cur >= this.nbre){
			this.cur = 0;	
		}
		this.mvt(this.cur);	
		
	}
	
	
	div_mea.onmouseover = function(){
		clearInterval(laClass.interv);
	}
	
	div_mea.onmouseout = function(){
		clearInterval(laClass.interv);
		laClass.setInterv();
	}
	
	this.setInterv = function(){
		this.interv = setTimeout(function(){laClass.plus()},this.tmps);
	}
	
	this.setInterv();
	
	this.verifLiens();
}
