(function($) {
	$(document).ready(function(){
	
		// Lightbox : Correctif pour les images en positionnement flottant disposant de loupe
		$('a[rel^=lightbox]')
		.addClass('zoomable')
		.fancybox({ Speed:1000, hideOnContentClick: false }) // on applique la fancybox
		.filter(':has(img)') // uniquement dans les liens ayant des images
		.append('<span class="zoom"></span>') // on ajoute un span contenant une image zoom
		.each(function() {
			var $this = $(this);
			// on définit les options css selon le type d'image
			if ($this.find('.illustr')) {
				$this.addClass('linkIllustr');
				$this.css({
					// width: $this.find('img').width()
				});
			} else if ($this.find('.illustr2')) {
				$this.css({
					position: 'relative',
					width: $this.find('img').width(),
					height: $this.find('img').height()
				});
			}
		})
		
		// plan interactif
    jQuery('a.group').fancybox({ 'hideOnContentClick': false });

		// dropdown menu de la carte							
		$('#dropdown').nmcDropDown({
			submenu_selector: 'ul',
			show: {opacity: 'show', top: '-=10px'},
			show_speed: 100,
			hide: {opacity: 'hide', top: '+=10px'},
			hide_speed: 300
		});
		
		// dropdown menu principal
		$('#dropdown2').nmcDropDown({
			submenu_selector: 'ul',
			show: {opacity: 'show', top: '-=10px'},
			show_speed: 100,
			hide: {opacity: 'hide', top: '+=10px'},
      hide_speed: 300
		});

		// Logotype moptip
		$('.logo_moptip').mopTip({'w':105,'style':"overOut",'get':"#moptip_logo"});		
		
		// alignement vertical du texte dans les boîtes
    $('.bigboxlien a strong').vAlign();
    $('.box_labelfull_link a.box_labelfull_link_txt strong').vAlign();
    $('.faq_titre_repeat h2.trigger a').vAlign();
		
		// galerie
		$('.gallery_cio_unstyled').addClass('gallery_cio'); // adds new class name to maintain degradability
		$('ul.gallery_cio').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				image.css('display','none').fadeIn(1000);
				caption.css('display','none').fadeIn(1000);
				var _li = thumb.parents('li');
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				thumb.fadeTo('fast',1).addClass('selected');
				image.attr('title','Image suivante >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				var _li = thumb.parents('li');
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)
			}
		});
		
		// egalisation des hauteurs des colonnes
    //var max = Math.max($('#rightbar').height(), $('#leftbar').height());
    //$('#rightbar').height(max+($('#rightbar').height() == max ? 0 : 165));
    //$('#leftbar').height(max);
    
    // faq
		$(".toggle_container").hide();
		$("h2.trigger").toggle(function(){
		  $(this).addClass("active"); 
		}, function () {
			$(this).removeClass("active");
		});
		$("h2.trigger").click(function(){
			$(this).next(".toggle_container").slideToggle("slow,");
		});
									
	});		
})(jQuery);								 			   