/**  覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧ｬ
    |														 |	
    |														 |
	 覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧
	|														 |
	|	S_NEXT : 	Static Number							 |
	|				POSITION COURANTE						 |
	|	 													 |		
	|   S_PREV :     Static Number							 |
	|				POSITION PRECEDENTE						 |
	|														 |
	|	PAUSE :     ETAT DE LA PAUSE / LECTURE POUR LE		 |
	|               DEFILEMENT DES NEWS                      |
	|														 |
	|   STATS : 	Static Boolean							 |
	|               SECURITE POUR DIFFERENCIER LE CLIC 		 |
	|               BOUTONS / LIEN							 |
	 ________________________________________________________
**/

var FX_infos 						= new Class (
{
	Implements:						[Events],
	
	/**	******************************************************
	 *						CONSTRUCTEUR
	 *                                                      **/
	initialize:						function (oB)
	{
		this.aElements				= $(oB.sBlock).getElements (oB.sFilter);
		this.nTotalEl				= this.aElements.length;
		this.aLinks					= $$(oB.sFilterLinks);
		this.init_statics();
		this.init_blocks ();
		this.mouseEvents ();
	},
	
	/** ******************************************************
	 *						INIT. STATICS VARS
	 *                                                      **/
	init_statics:					function ()
	{
		if (typeof this.S_NEXT=='undefined') this.S_NEXT 	= 0;
		if (typeof this.S_PREV=='undefined') this.S_PREV 	= 0;		
		if (typeof this.PAUSE=='undefined')  this.PAUSE 	= false;
		if (typeof this.STATS=='undefined')  this.STATS 	= false;
	},
	
	/** ******************************************************
	 *						INIT. BLOCKS TO HIDE
	 *                                                      **/
	init_blocks:					function ()
	{
		for (var i=0; i<this.nTotalEl; i++)
		{
			if (i==0) 
			{
				this.aElements[i].setStyle ('display', 'block');
				continue;
			}
			this.aElements[i].setStyle ('display', 'none');
			this.aElements[i].fade (0);
		}
	},
	
	/** ******************************************************
	 *						NAV. ARROWS
	 *                                                      **/
	init_arrows:					function (oB)
	{
		this.aNavs					= $(oB.sBlock).getElements (oB.sFilter);		
		this.btnPause				= $(oB.sBlock).getElement (oB.sFilterPause);
		this.event_arrows ();
		// COUNTER
		if (oB.bCounter)
		{
			this.eCounter			= $('counter');
			this.eCounter.set ('text', '1/'+(this.nTotalEl));
		}
	},
	
	/** ******************************************************
	 *						CALL FUNCTION WITH INTERVAL 
	 *                                                      **/
	call_periodic:					function (s)
	{
		var o						= this;								// POINTEUR		
		this.change_content			= function ()
		{						
			if (!o.PAUSE)
			{
				with (o)
				{					
					// INC. STATIC
					if (S_NEXT+1>(nTotalEl-1))
						S_NEXT		= 0;
					else
						S_NEXT++;					
				}
				o.update_content ();
				o.update_counter ();
			}
		};
		this.change_content.periodical (s*1000);
	},
	
	update_content:					function ()
	{
		with (this)
		{
			// CHANGE
			aElements[S_PREV].fade(0);
			aElements[S_PREV].setStyle ('display', 'none');
			aElements[S_NEXT].setStyle ('display', 'block');
			aElements[S_NEXT].fade(1);
			S_PREV					= S_NEXT;					
		}
		this.STATS					= false;
	},
	
	update_counter:					function ()
	{
		var num						= (this.S_NEXT==0) ? 1:(this.S_NEXT+1);
		this.eCounter.set ('text', num + '/' + this.nTotalEl);
	},
	
	update_btn_pause:				function (btn)
	{
		if (this.PAUSE)
			btn.setProperty ('src', '/picture_library/commun/pause_on.gif');
		else
			btn.setProperty ('src', '/picture_library/commun/pause_off.gif');
	},
	
	/** ******************************************************
	 *						MOUSE EVENTS
	 *                                                      **/
	mouseEvents:					function ()
	{
		var o						= this;								// POINTEUR
		this.aLinks.each (function (elValue)
		{
			elValue.addEvents (
			{
				'click':			function (e)
				{
					e.stop ();
					o.STATS			= false;
					if (!o.STATS)
						document.location.href = this.href;
				}
			});
		});
	},
	
	event_arrows:					function ()
	{			
		var o						= this;								// POINTEUR
		this.aNavs.each (function (elValue)
		{
			elValue.addEvents (
			{
				'click':			function (e)
				{					
					e.stop ();					
					o.STATS			= true;
					switch (this.id)
					{
						case "gauche":							
							var btn				= o.btnPause;
							o.PAUSE				= true;
							o.update_btn_pause (btn);
							if (o.S_NEXT-1<0)
							{
								o.S_NEXT			= (o.nTotalEl-1);
								o.update_content ();
								o.update_counter ();								
							}
							else
							{
								(o.S_NEXT--);
								o.update_content ();																
								o.update_counter ();
							}
							break;
						case "droite":							
							var btn				=o.btnPause;
							o.PAUSE				= true;
							o.update_btn_pause (btn);
							if (o.S_NEXT+1>(o.nTotalEl-1))
							{
								o.S_NEXT			= 0;
								o.update_content ();																	
								o.update_counter ();
							}
							else
								(o.S_NEXT++);
								o.update_content ();								
								o.update_counter ();
							break;
						case "pause":
							var btn				= $(this).getElement('img');							
							o.PAUSE				= (o.PAUSE===true) ? false : true;
							if (o.PAUSE)
								btn.setProperty ('src', '/picture_library/commun/pause_on.gif');
							else
								btn.setProperty ('src', '/picture_library/commun/pause_off.gif');
							break;
						case "start":
							o.PAUSE				= false;
							break;
					}					
				}
			});
		});
	}
	
});
window.addEvent ("domready", function ()
{	
	// __________________________________________________
	// INIT. GALLERY INFOS			
	
	// EVITE UNE ERREUR JAVASCRIPT
	if (typeof FX_infos!='undefined')
	{
		var oActus				= {sBlock:'blockActus', sFilter:'div[class=actualites2]', sFilterLinks:'a[rel=link]'};	
		var oNav				= {sBlock:'arrows_nav', sFilter:'a', sFilterPause:'img[id=picPause]', bCounter:true};
		var oInfos				= new FX_infos (oActus);
		var s					= 15;		
		oInfos.init_arrows (oNav);
		oInfos.call_periodic (s);
	}
	// __________________________________________________
	// INIT. TOOLTIPS INFOS
	if (typeof My_tooltips!='undefined')
	{
		var oParams				= {sFilter:'li[class=trigger]', sName:'bulle_'};
		var myTips				= new My_tooltips (oParams);
	}
	
});