window.addEvent('domready', function(){
	var wrapper = $('cadre'); // The outer wrapper
	var carousel= $('carrousel'); // The inner wrapper
	var item_width = 652;

	var animation = new Fx.Tween( carousel, {duration: 500} );
	var animation2 = new Fx.Tween( wrapper, {duration: 500} );

	function icarrousel( num ){
		//position = parseInt(carousel.getStyle('left'));
		var newposition = num * item_width * (-1);
		var i = 0;
		$$('#carrousel ul').each(function(el){
			W = parseInt( el.getStyle('height'));
			if( i == num ){w = W;}
			i++;
		});
		w += 15;

		animation.start( 'left',newposition );
		animation2.start( 'height',w+'px' );
	}
	if($chk(wrapper)){
		ul = wrapper.getElement('ul');
		ww = ul.getStyle('height').toInt() + 15;
		animation2.start('height',ww+'px');
	}
	$$('#frame span').each(function(el){
		el.addEvent('click', function(event){
			event.stop();
			var tmp = el.get('id').split('_');
			var num = tmp[1].toInt();
			icarrousel( num );
		});
	});
});
