$(document).ready(function(){

	$("#MasterUl > div.MakeMenu").each( function(){
		
		var loc  = ""+window.location;
		var Link = ""+$(this).children("a").attr('href');
	
		Link = Link.replace(".html","");
		
		if( Link.search("-cate-") != -1){
		
			var Tempo = Link.split('-cate-');
			Link = Tempo[0];
		}
		
		if( loc.search(""+Link+"") != -1 ){
		
			$(this).children("a").attr('id','active');
			$(this).attr('id','activeMenu');
				
		}
	});
	
	/* 
	 |
	 | JS POUR TRANSFORMER NOS IMAGES EN VIDEO YOUTUBE, DAILYMOTION OU AUTRE SWF LISABLE SANS PLAYER FLV
	 |
	 */
	
	// Ajout du rollover sur les images
	$(".rollover img").hover(
			function()
			{
				this.src = this.src.replace("-off","-on");
			},
		function()
		{
			this.src = this.src.replace("-on","-off");
		}
	);
	
	$("img.youtube").flash(
			  { },   
	  		  { version: 8 },
	  		  function(htmlOptions) {
	  		  	$this = $(this);
	  		  	
	  		  	var LinkOfVideo = $this.attr('alt');
	  		  	
	  		  	if( LinkOfVideo.search("dailymotion") != -1  ){
			  		
			  		if( LinkOfVideo.search("related=0") == -1 )
			  			LinkOfVideo += "&amp;related=0";
			  		
			  		LinkOfVideo = LinkOfVideo.replace(/dailymotion.com\/video/,"dailymotion.com\/swf");
			  	}
	  		    else if( LinkOfVideo.search("vimeo") != -1  ){

			  		if( LinkOfVideo.search("vimeo.com") ){
			  			
			  			
			  			LinkOfVideo = LinkOfVideo.replace(/vimeo.com\//,"vimeo.com\/moogaloop.swf\?clip_id=");
			  			
			  		}
			  		
			  	}
	  		  	else if( LinkOfVideo.search("youtube") != -1  ){

	  		  		if( LinkOfVideo.search("watch?v=") ){
	  		  			
	  		  			LinkOfVideo += "&amp;hl=fr&amp;fs=1&amp;";
	  		  			LinkOfVideo = LinkOfVideo.replace(/watch\?v=/,"v/");
	  		  		}
	  		  		
	  		  	}
	  		    
	  		  	
	  		  	htmlOptions.src    = LinkOfVideo;
	  		  	
	  		  	if( $this.css("width") != 'auto' && $this.css("width") != '0px')
	  		  		htmlOptions.width  = $this.css("width");
	  		  	
	  		  	else
	  		  		htmlOptions.width  = "320px";
	  		  	
	  		  	if( $this.css("height") != 'auto' && $this.css("height") != '0px')
	  		  		htmlOptions.height = $this.css("height");
			  	
			  	else
			  		htmlOptions.height  = "240px";
	  		  	
	  		  	
	  		  	$this.before($.fn.flash.transform(htmlOptions));
	  		  	
	  		  	$this.remove();
	  		  });

	/* 
	 |
	 | JS POUR AFFICHER OU NON LA LEGENDE SUR UNE IMAGE TOUTES LA MISE EN PAGE EST GERE VIA CSS
	 |
	 */

	$('.fromsakka').jcaption({
		
		copyStyle: true,
		autoWidth: true,
		animate: false
	});
	
	/* 
	 |
	 | TOUTE IMAGE POINTANT VIA UN LIEN SUR UNE IMAGE SERA ZOOMER AUTOMATIQUEMENT
	 |
	 */

	$("a.none").zoomimage({
		controls:0,
		caption:0
	});
	
	$("a.fromsakka").zoomimage({
		controls:0,
		caption:0
	});
	
	/* 
	 |
	 | PREPARATION POUR L'AFFICHAGE EN GALLERY
	 |
	 */
	$(function() {
  
		if( $('.ad-gallery') ){
		
			var galleries = $('.ad-gallery').adGallery();
		
			/*
			| ICI ON VA APPLIQUER LE SENS DE TRANSITION QUE L'ON VEUT UTILISER SUR LA MAISE EN GRAND DE PHOTO
			|
			| Valeur possible : 
			| slide-hori > Slide horizontal
			| slide-vert > Slide vertical</option>
			| resize > Shrink/grow
			| fade > Fade
			|
			*/
			if( galleries[0] )
				galleries[0].settings.effect = "slide-hori";
		
			/*
				Option pour lancer ou non la lecture automatique ;)
			$('#toggle-slideshow').click(
			function() {
				galleries[0].slideshow.toggle();
				return false;
			}
			);*/
		}
	});
});

