window.addEvent('domready', function(e){
	/* START ACTU BLOCK TWEENING */
	if ( $('tween_nav') )
	{
		$$('#tween_nav .element').setStyle('opacity', 0);
		var oActusTweenTab = new TweenTab(
			'tween_nav',
			{
				cssSelector : {
					link : '.tween_navig li a',
					block : '.element'
				},
				element: {
					blockPrefix : 'TweenActu',
					linkPrefix	: 'TweenActuLink'
				},
				move : {
					property	: 'opacity',
					from		: '0',
					to			: '1'
				},
				auto_scrolling : {
					active		: true,
					period			: 10000,
					period_restart	: 10000
				},
				activeLink: function(sId) {
					$(sId).addClass('active');
				},
				disableLink: function(sId) {
					$(sId).removeClass('active');
				}
		});

		oActusTweenTab.changeElement(0);

		/*navigation with arrows*/
		$('tween_nav').getElement('.right_arrow').addEvents(
		{
			'click': function()
			{
				if( this.getSCurrentId() != null && this.bHidden == false )
				{
					this.stopAutoScrollingPeriod();
					if( this.getSCurrentId().toInt() <= this.getSLastId() )
						this.changeElement(this.getSCurrentId().toInt() + 1);
					this.startAutoScrollingPeriod();
				}
			}.bind(oActusTweenTab)
		});

		$('tween_nav').getElement('.left_arrow').addEvents(
		{
			'click': function()
			{
				if( this.getSCurrentId() != null && this.bHidden == false )
				{
					this.stopAutoScrollingPeriod();
					if( this.getSCurrentId().toInt() - 1 >= 0 )
						this.changeElement(this.getSCurrentId().toInt() - 1);
					this.startAutoScrollingPeriod();
				}
			}.bind(oActusTweenTab)
		});
		/*end navigation with arrows*/

		/* STOP ANIMATION WHEN USER IS OVER AN ELEMENT */
		$$('#tween_nav .element').each( function( oItem )
		{
			oItem.addEvents({
				'mouseover': function()
				{
					if( oActusTweenTab )
						oActusTweenTab.stopAutoScrollingPeriod();
				},

				'mouseout': function()
				{
					if( oActusTweenTab )
						oActusTweenTab.startAutoScrollingPeriod();
				}
			})
		});
		/* END STOP ANIMATION WHEN USER IS OVER AN ELEMENT */
	}
	/* END ACTU BLOCK TWEENING */

	/* START THEMATIQUE BLOCK TWEENING */
	if ( $('tween_nav_tem') )
	{
		$$('#tween_nav_tem .element').setStyle('opacity', 0);
		var oTemTweenTab = new TweenTab(
			'tween_nav_tem',
			{
				cssSelector : {
					link : '.tween_navig li a',
					block : '.element'
				},
				element: {
					blockPrefix : 'TweenTem',
					linkPrefix	: 'TweenTemLink'
				},
				move : {
					property	: 'opacity',
					from		: '0',
					to			: '1'
				},

				auto_scrolling : {
					active		: true,
					period			: 10000,
					period_restart	:10000
				},
				activeLink: function(sId)
				{
					$(sId).addClass('active');
				},
				disableLink: function(sId)
				{
					$(sId).removeClass('active');
				}
			}
		);
		oTemTweenTab.displayElement(0);

		/*navigation with arrows*/
		$('tween_nav_tem').getElement('.right_arrow').addEvents(
		{
			'click': function()
			{
				if( this.getSCurrentId() != null && this.bHidden == false )
				{
					this.stopAutoScrollingPeriod();
					if( this.getSCurrentId().toInt() <= this.getSLastId() )
						this.changeElement(this.getSCurrentId().toInt() + 1);
					this.startAutoScrollingPeriod();
				}
			}.bind(oTemTweenTab)
		});

		$('tween_nav_tem').getElement('.left_arrow').addEvents(
		{
			'click': function()
			{
				if( this.getSCurrentId() != null && this.bHidden == false )
				{
					this.stopAutoScrollingPeriod();
					if( this.getSCurrentId().toInt() - 1 >= 0 )
						this.changeElement(this.getSCurrentId().toInt() - 1);
					this.startAutoScrollingPeriod();
				}
			}.bind(oTemTweenTab)
		});
		/*end navigation with arrows*/

		/* STOP ANIMATION WHEN USER IS OVER AN ELEMENT */
		$$('#tween_nav_tem .element').each( function( oItem )
		{
			oItem.addEvents({
				'mouseover': function()
				{
					if( oTemTweenTab )
						oTemTweenTab.stopAutoScrollingPeriod();
				},

				'mouseout': function()
				{
					if( oTemTweenTab )
						oTemTweenTab.startAutoScrollingPeriod();
				}
			})
		});
		/* END STOP ANIMATION WHEN USER IS OVER AN ELEMENT */
	}
	/* START THEMATIQUE BLOCK TWEENING */
	
	
	/*reporting block_moving's px on slides if disappear and only for the home page*/
	if(!$('block_moving')&&$('mise_en_avant'))
	{
		$$('.tween_tabs').setStyle('width','340px');
		$$('.tween_tabs .content_tab').setStyle('width','300px');
		$$('.tween_tabs .element').setStyle('width','260px');
	}
});	
