//Carrousel v1

var _etatBt = 0;
var _tI;
var _pI = 2;
var timy;

function co_initialisation(maxtI){
	_tI = maxtI;
	_one = _tI-1;
	_two = _tI-2;
	$("#img_2").css({ top: "55px", left: "0px", height:"52px", width:"52px", zIndex:"1" })
	$("#img_2 > img").css({height:"50px" })
	$("#img_1").css({ top: "30px", left: "84px", height:"102px", width:"102px", zIndex:"2" })
	$("#img_1 > img").css({height:"100px"})
	$("#img_0").css({ top: "5px", left: "220px", height:"152px", width:"152px", zIndex:"6" })
	$("#img_0 > img").css({height:"150px"})
	$("#img_"+_one).css({ top: "30px", left: "406px", height:"102px", width:"102px", zIndex:"3" })
	$("#img_"+_one+" > img").css({height:"100px"})
	$("#img_"+_two).css({ top: "55px", left: "540px", height:"52px", width:"52px", zIndex:"4" })
	$("#img_"+_two+" > img").css({height:"50px"})
	timy = setTimeout(function(){co_next()}, 5000 ) ;
}

function co_next(){
	if(_etatBt!=1){
		_etatBt=1;
		
		_nImg0=(_pI==_tI-1) ? 0 : _pI+1;
		_nImg1=_pI;
		_nImg2=(_pI-1 < 0 )? _tI-(1-_pI) : _pI-1;
		_nImg3=(_pI-2 < 0 )? _tI-(2-_pI) : _pI-2;
		_nImg4=(_pI-3 < 0 )? _tI-(3-_pI) : _pI-3;
		_nImg5=(_pI-4 < 0 )? _tI-(4-_pI) : _pI-4;
		
		
		
		$("#img_"+_nImg0).css({ height: "52px", width:"52px", top: "55px", left:"-52px", zIndex:"1", opacity:0 });
		$("#img_"+_nImg0+" > img").css({ height: "50px" });
		$("#img_"+_nImg1).css({ zIndex:"2" });
		$("#img_"+_nImg2).css({ zIndex:"3" });
		$("#img_"+_nImg3).css({ zIndex:"6" });
		$("#img_"+_nImg4).css({ zIndex:"5" });
		$("#img_"+_nImg5).css({ zIndex:"4" });
		
		$("#img_"+_nImg0).animate({ left:"0px", opacity:100 }, 800  );
		$("#img_"+_nImg1).animate({ height: "102px", width:"102px", top: "30px", left:"84px"}, 800 );
		$("#img_"+_nImg1+" >img").animate({ height: "100px"}, 800 );
		$("#img_"+_nImg2).animate({ height: "152px", width:"152px", top: "5px", left:"220px"}, 800 );
		$("#img_"+_nImg2+" >img").animate({ height: "150px"}, 800 );
		$("#img_"+_nImg3).animate({ height: "100px", width:"102px", top: "30px", left:"406px"}, 800 );
		$("#img_"+_nImg3+" >img").animate({ height: "100px"}, 800 );
		$("#img_"+_nImg4).animate({ height: "52px", width:"52px", top: "50px", left:"540px"}, 800 );
		$("#img_"+_nImg4+" >img").animate({ height: "50px"}, 800 );
		$("#img_"+_nImg5).animate({ left:"592px"}, 800 , function(){co_endAnimNext()} );
		
	}
}

function co_endAnimNext(){
	_pI=(_pI==_tI-1) ? 0 : _pI+1 ;
	_etatBt = 0;
	clearTimeout(timy);
	timy = setTimeout(function(){co_next()}, 5000 ) ;
}
