// Script encodé avec http://javascriptcompressor.com/
// avec l'option "Base62 encode"

var $$ = $.fn;

var settings_banniere = {
	'speed': 1500, // En milliseconde
	'delay': 5000, // En milliseconde
	'runningclass':     'innerfade',
	'children':         null
};

$$.extend({
	
	Bannieres_publicitaire : 
	{
		Ready : function()
		{
			// *********************************************************************************************************
			// Gestionnaire d'évènement sur le diaporama de la bannière publicitaire :
			// *********************************************************************************************************
			$('div.tmpSlide_bann')
			
			.hover(
				function() {
					$("div[name='cadre_texte_droite_bann']").slideDown(50);
				},
				function() {
					$("div[name='cadre_texte_droite_bann']").slideUp(50);
					// $("div[name='cadre_texte_droite_bann']").each(function(){
						// var div_en_cours2 = $(this).attr("id");
						// $("#" + div_en_cours2).slideUp(50);
					// }); 
				}
			)
			
			.click(function(){
				//alert("test !");
			});
			
			// *********************************************************************************************************
			// Gestionnaire d'évènement sur les boutons de contrôls du diaporama de la bannière publicitaire :
			// *********************************************************************************************************
			$('div.tmpSlideshowControl').hover(
				function() {
					$(this).addClass('tmpSlideshowControlOn');
				},
				function() {
					$(this).removeClass('tmpSlideshowControlOn');
				}
			)
			
			.click(
				function() {

					$$.Bannieres_publicitaire.Interrupted = false;
					
					clearTimeout(interval);
					
					// L'image en cours devient l'image précédente pour effectuer le fondu
					$$.Bannieres_publicitaire.Last = $("#courant_bann").val();
					
					//alert($$.Bannieres_publicitaire.Last);
					var elem_id = $(this).attr('id');
					
					var temp = elem_id.split("-");
					
					// Récupération de l'index de l'image cliquée
					$$.Bannieres_publicitaire.Counter = temp[1];
					
					// Calcul du nombre d'image dans le diaporama !
					nb_image_total = $('div#portfolio_bann > div').size();
					
					//alert('Nb images : ' + nb_image_total + '\nLast : ' + $$.Bannieres_publicitaire.Last + '\nCourant : ' + $$.Bannieres_publicitaire.Counter);

					$("#courant_bann").val($$.Bannieres_publicitaire.Counter);
					$("#last_bann").val($$.Bannieres_publicitaire.Last);
					
					$('div.tmpSlideshowControl').removeClass('tmpSlideshowControlActive');
					
					$('div#tmpSlideBann-' + $$.Bannieres_publicitaire.Last).fadeOut(settings_banniere.speed);
					
					$('div#tmpSlideBann-' + $$.Bannieres_publicitaire.Counter).fadeIn(settings_banniere.speed);

					$('div#tmpSlideshowNum-' + $$.Bannieres_publicitaire.Last).hide();
					$('div#tmpSlideshowNum-' + $$.Bannieres_publicitaire.Counter).show();
					
					var cpt_marge_G = $$.Bannieres_publicitaire.Counter - 1;
			
					$('div#tmpSlideshowNum-' + $$.Bannieres_publicitaire.Counter).css("margin-left", (cpt_marge_G * 13) + "px");
					
					$('div#tmpSlideshowControl-' + $$.Bannieres_publicitaire.Last).removeClass('tmpSlideshowControlActive');
					$('div#tmpSlideshowControl-' + $$.Bannieres_publicitaire.Counter).addClass('tmpSlideshowControlActive');

					if($$.Bannieres_publicitaire.Counter<5)
						$$.Bannieres_publicitaire.Counter++;
					else
						$$.Bannieres_publicitaire.Counter=1;
						
					interval = setTimeout('$$.Bannieres_publicitaire.Transition();', settings_banniere.delay);
				}
			);

			// **************************************
			//    Fin du gestionnaire d'évènement 
			// **************************************
			
			this.Counter = 1;
			this.Interrupted = false;

			this.Transition();
		},

		Transition : function()
		{
			
			if (this.Interrupted) {
				return;
			}
			
			nb_image_total = $('div#portfolio_bann > div').size();
			
			this.Last = this.Counter - 1;
			
			// alert(nb_image_total);
			
			// $('div.tmpSlideshowControl').removeClass('tmpSlideshowControlActive');
			
			if (this.Last < 1) {
				this.Last = nb_image_total;
			}
			
			$("#courant_bann").val( $$.Bannieres_publicitaire.Counter );
			$("#last_bann").val( $$.Bannieres_publicitaire.Last );
			
			$('div#tmpSlideBann-' + this.Last).fadeOut(settings_banniere.speed);
				
			// $('div#tmpSlideshowNum-' + $$.Bannieres_publicitaire.Last).hide();
			// $('div#tmpSlideshowNum-' + $$.Bannieres_publicitaire.Counter).show();
			
			// var cpt_marge_G = $$.Bannieres_publicitaire.Counter - 1;
			
			// $('div#tmpSlideshowNum-' + $$.Bannieres_publicitaire.Counter).css("margin-left", (cpt_marge_G * 13) + "px");
				
			// $('div#tmpSlideshowControl-' + $$.Bannieres_publicitaire.Last).removeClass('tmpSlideshowControlActive');
			// $('div#tmpSlideshowControl-' + $$.Bannieres_publicitaire.Counter).addClass('tmpSlideshowControlActive');
			
			$('div#tmpSlideBann-' + $$.Bannieres_publicitaire.Counter).fadeIn(settings_banniere.speed);
			

			$$.Bannieres_publicitaire.Counter++;

			if ($$.Bannieres_publicitaire.Counter > nb_image_total) {
				$$.Bannieres_publicitaire.Counter = 1;
			}
			
			interval = setTimeout('$$.Bannieres_publicitaire.Transition();', settings_banniere.delay);
		}
  }
});

$(document).ready(
	function() {
	
		$$.Bannieres_publicitaire.Ready();
		
	}
);

function removeFilter(element) {
	if(element.style.removeAttribute){
		element.style.removeAttribute('filter');
	}
}
