/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */
(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'imgs/lightbox/lightbox-ico-loading.gif',imageBtnPrev:'imgs/lightbox/lightbox-btn-prev.gif',imageBtnNext:'imgs/lightbox/lightbox-btn-next.gif',imageBtnClose:'imgs/lightbox/lightbox-btn-close.gif',imageBlank:'imgs/lightbox/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
_set_image_to_view();}
function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
_enable_keyboard_navigation();}
function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
function _disable_keyboard_navigation(){$(document).unbind();}
function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}
function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
	
/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

function StyleSwitcher()
{
	
	$('#styleswitcher .styleswitch').click(function()
	{
		$(this).attr('href', location.href);
		switchStylestyle(this.getAttribute("rel"));
		return false;
	});
	c = readCookie('style');
	if (c){
		switchStylestyle(c);
	}else{
		c = $($('link[@rel*=style][type=text/css][title]')[0]).attr('title');
	}
}

function switchStylestyle(styleName)
{
	$('#styleswitcher .styleswitch').removeClass('active');
	$('#styleswitcher .styleswitch[rel=' + styleName + ']').addClass('active');
	$('link[@rel*=style][type=text/css][title]').each(function(i)
	{
		this.disabled = true;
		if (this.getAttribute('title') == styleName){
			this.disabled = false;
		}
	});
	c = styleName;
	createCookie('style', styleName, 365);
	switchStyleDisableOutils(styleName);
}

function switchStyleDisableOutils(styleName)
{
	$('#outil_textemoins').removeClass('disabled');
	$('#outil_texteplus').removeClass('disabled');
	styles = $('link[@rel*=style][type=text/css][title]');
	styles.each(function(i)
	{
		if(styleName == this.getAttribute('title'))
		{
			if(i==0)
			{
				$('#outil_textemoins').addClass('disabled');
				return false;
			}else if(i==styles.length-1){
				$('#outil_texteplus').addClass('disabled');
				return false;
			}
		}
	});
}


(function($) {
	$.fn.slideShow = function(settings) {
		settings = jQuery.extend({
			fadeTime:		1000,
			fadeDelay:		3000,
			slideShowGo:''
		},settings);
		
		var jQueryMatchedObj = this;
		pics = $(this).data('diaporama');
		dossier = $(this).data('dossier');
		
		//Prepare le tableau des images
		//pics = new Array($(this).attr('src') + '§§' + $(this).attr('alt'));	//Première image deja dans le code source
		//pics = pics.concat($(this).attr('rel').split('|'));	//Autres images à charger
		looped = false;
		if(pics.length > 1 )
		{
			current = 0;
			$(this).append('<img class="active" src="' + dossier + '/' + pics[0] + '" alt="" />');
			_showNext();
		}
			
			
		function _showNext()
		{
			$.clearTimer(settings.slideShowGo);
			
			settings.slideShowGo = $.timer(settings.fadeDelay,function(){
				var actuelle = jQueryMatchedObj.children('img.active');
				current++;
				if(current >= pics.length)
				{
					looped = true;
					current = 0;
					
				}
				var data = pics[current];
				jQueryMatchedObj.children('img').removeClass('activeFin');
				$(actuelle).removeClass('active').addClass('activeFin');
				
				//Image deja chargée ?
				if(!looped)
				{
					$('<img class="active" src="' + dossier+'/'+data + '" alt="" style="display:none;" />').insertAfter(actuelle).load(function () {
						$(this).fadeTo(settings.fadeTime,1);
						_showNext();
					});
				}else{
					//Image existe deja
					if($(actuelle).next('img').length==0)
						var anime = jQueryMatchedObj.children('img:first').first();
					else
						var anime = $(actuelle).next('img');
					$(anime).hide().removeClass('activeFin').addClass('active').fadeTo(settings.fadeTime,1);
					_showNext();
				}
				
			});
		}
	}
})(jQuery);



/* 
 * Cookie functions http://www.quirksmode.org/js/cookies.html 
 *
 */
 
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}



/*
 * jQuery Timer Plugin
 * http://www.evanbot.com/article/jquery-timer-plugin/23
 *
 * @version      1.0
 * @copyright    2009 Evan Byrne (http://www.evanbot.com)
 */ 

jQuery.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

jQuery.clearTimer = function(a){
	if(typeof(a) != 'undefined')
		clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};






/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!
/***************************/
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#envoi_ami_background").css({
			"opacity": "0.7"
		});
		$("#envoi_ami_background").fadeIn("slow");
		$("#envoi_ami").fadeIn("slow");
		popupStatus = 1;
	}
}
//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#envoi_ami_background").fadeOut("slow");
		$("#envoi_ami").fadeOut("slow");
		popupStatus = 0;
	}
}
//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#envoi_ami").height();
	var popupWidth = $("#envoi_ami").width();
	//centering
	$("#envoi_ami").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#envoi_ami_background").css({
		"height": windowHeight
	});
	return false;
}



$(document).ready(function() {
	
	/* Init le styleswitcher */
	c = '';

	StyleSwitcher();

	/* Enrichit le menu principal */
	$('#colz ul').removeClass('hover');
	$('#colz ul ul').append('<li class="end"></li>');
	//var lis = $('#colz > ul > li').length;
	/*$('#colz > ul > li').each(function(i){
		$(this).css('z-index', lis+1-i);
	});*/
	$('#colz > ul > li').mouseenter(function() 
	{
		$(this).css('z-index', 2);
		var tgt = $(this);
		menuGo = $.timer(500,function(){
			tgt.find('ul').show();
			//tgt.find('ul').fadeIn("fast");
		});
	}).mouseleave(function() 
	{
		$(this).css('z-index', 1);
		if(typeof(menuGo)=='object')
			$.clearTimer(menuGo);
		$(this).find('ul').hide();
	});
	
	
	/* Coins */
	$('.coin1, .coin2, .coin3, .fieldset').append('<div class="c1"></div><div class="c2"></div><div class="c3"></div><div class="c4"></div>');
	
	/* Les outils en haut de contenu */
	switchStyleDisableOutils(c);
	$('#outil_imprime').click(function() 
	{
		window.print();
		return false;
	});
	$('#outil_textemoins').click(function() 
	{
		styles = $('link[@rel*=style][type=text/css][title]');
		styles.each(function(i)
		{
			if(c == this.getAttribute('title') && i>0)
			{
				var style_go = styles[i-1];
				switchStylestyle(style_go.getAttribute('title'));
				return false;
			}
		});
		return false;
	});
	$('#outil_texteplus').click(function() 
	{
		styles = $('link[@rel*=style][type=text/css][title]');
		styles.each(function(i)
		{
			if(c == this.getAttribute('title') && i<styles.length-1)
			{
				var style_go = styles[i+1];
				switchStylestyle(style_go.getAttribute('title'));
				return false;
			}
		});
		return false;
	});
	$('#outils').show();


	/* Onglets colonne */
	$('.onglets_do').each(function()
	{
		var parent = $(this);
		$(this).prepend('<div class="onglets_tab"></div>');
		//Placer les boutons en haut du bloc
		$(this).children('h3').each(function(i)
		{
			if(i>0)
				$(this).next('.onglets_cont').hide();		//Ferme tout sauf le premier
			$(parent).children('.onglets_tab').append($(this));	//Déplace le bouton en haut
			$(this).append('<span></span>');
		});
		
		$(this).find('h3').addClass('js').click(function()
		{
			$(this).addClass('current');
			$(this).siblings('h3.current').removeClass('current');
			var tgt = $(parent).children('.onglets_cont:eq('+ $(this).index() +')');
			if($(tgt).not(':visible'))
			{
				$(tgt).show();
				$(tgt).siblings('.onglets_cont:visible').hide();
			}
		});
		if($(this).find('.onglets_tab h3.current').length==1)
		{
			$(this).find('.onglets_tab h3.current').click();
		}else{
			$(this).find('.onglets_tab h3:first').click();
		}
		
	});
	
	/* CosneMag */
	var mag_space = 80;
	var maxDisplay = 6;
	var magLeft = Math.round(maxDisplay/2 * mag_space) - mag_space*.5;
	var lefted = 0;
	var moveBy = 1;
	var firstOn = true;
	var contW = moveW = moveToPos = 0;
	var totalItems = $('#mag dl').length;
	
	if($('#mag').length > 0)
	{

		
		function MagShow(idx)
		{
			var elt = $('#mag dl').eq(idx);
			$(elt).addClass('current').stop().animate(
			{
				top: '20px',
				left:(idx*mag_space+magLeft-25)+'px'
			}, 300, function() {
				// Animation complete.
			}).find('img').stop().animate(
			{
				width: '100px'
			}, 300, function() {
				// Animation complete.
				$(this).parents('dd').siblings().stop().fadeTo(300,1);
			});
		}
		function MagHide(idx)
		{
			var elt = $('#mag dl').eq(idx);
			$(elt).children(':not(.image)').stop().hide();
			$(elt).removeClass('current').stop().animate(
			{
				top: '55px',
				left:(idx*mag_space+magLeft)+'px'
			}, 250, function() {
				// Animation complete.
			}).find('img').stop().animate(
			{
				width: '50px'
			}, 250, function() {
				// Animation complete.
				
			});
		}
		function BtnsShow(X)
		{
			if(X<0)
			{
				$('#magL').show();
			}else{
				$('#magL').hide();
			}
			if(-X < totalItems-1)
			{
				$('#magR').show();
			}else{
				$('#magR').hide();
			}
		}
	
		$('#mag').addClass('js').wrapInner('<div id="mag_cont"><div id="mag_move"></div></div>').find('dl').each(function(i)
		{
			$(this).children(':not(.image)').hide();
			
			contW = $('#mag_cont').width();
			moveW = $('#mag_move').width();
			
			$(this).css('left', (i*mag_space+magLeft) + 'px');
			
			//Affiche le premier
			if(i==0)
			{
				MagShow(0);
			}
		});
		
		if(totalItems > 1)
		{
			$('#mag').append('<div id="magL"></div><div id="magR"></div>');
			BtnsShow(-lefted);
			$('#magR').click(function()
			{
				moveToPos = lefted + moveBy;
				if(moveToPos >= maxDisplay-totalItems)
				{
					MagHide(lefted);
					MagShow(moveToPos);
					lefted = moveToPos;
					BtnsShow(-lefted);
					$('#mag_move').stop().animate(
					{ 
						left:(-lefted*mag_space)+'px'
					}, 300);
					$('#mag_move dl:lt('+Math.abs(lefted)+'):gt('+(Math.abs(lefted)+6)+')').hide();
				}
			});
			$('#magL').click(function()
			{
				moveToPos = lefted - moveBy;
				if(moveToPos >= 0)
				{
					MagHide(lefted);
					MagShow(moveToPos);
					lefted = moveToPos;
					BtnsShow(-lefted);
					$('#mag_move').stop().animate(
					{ 
						left:(-lefted*mag_space)+'px'
					}, 300);
				}
			});
		}
	}
	
	//Ajax data auto lien/replace
	$('#content .ajax_link').each(function(i)
	{
		var lien = $(this).attr('href');
		$(this).after('<div class="ajax_content"></div>');
		$(this).click(function()
		{
			if($(this).hasClass('loaded'))
			{
				$(this).removeClass('loaded').next('.ajax_content').stop().slideUp('slow');
			}else{
				$(this).addClass('loading');
				$.ajax({
					type: "GET",
					url: lien,
					data: "print=true",
					cache: false,
					context: this,
					success: function(html){
						$(this).removeClass('loading').addClass('loaded').next('.ajax_content').css('height','auto').stop().hide().html(html).slideDown('slow');
					}
				});
			}
			return false;
		});
	});
	
	//Auto expand elements	
	if($('#content .expandType').length > 0){
		//Detecte le tag à definir comme bouton
		$('#content .expandType').each(function(){
			var tag = $(this).attr('class').split(' ').pop();
			$('#content ' + tag).each(function(){
				//tag au dessus pour arret ?
				var lvl = tag.substr(1,2);
				var tagsUp = '';
				for(i=1;i<lvl;i++)
					tagsUp += ',' + 'h' + i;
				
				
				$(this).nextUntil(tag+tagsUp).wrapAll('<div class="expand" style="display:none;"></div>').wrapAll('<div class="padder"></div>');
				$(this).click(function(){
					var tgt = $(this).next('.expand');
					if($(tgt).is(":hidden"))
					{
						tgt.slideDown('slow');
						$(this).addClass('expandMeOut');
					}else{
						tgt.slideUp('slow');
						$(this).removeClass('expandMeOut');
					}
				}).addClass('expandMe');
			});
			$(this).parent('p').remove();
		});
	}
	
	/* Egalise les 2 colonnes principales si besoin */	
	var h1 = $('#contenu').height();
	var h2 = $('#contenu2').height();
	if(h1<h2)
	{
		$('#contenu:not(.noautosize)').css('min-height', (h2-54)+'px');
	}
	
	/* Lightbox */
	var name = $('#content a').each(function()
	{
		if($(this).children(':first-child').is('img')){
			var href = $(this).attr('href');
			
			var ext = href.substring(href.length-3,href.length);
			if(ext=='jpg' || ext=='gif' || ext=='png')
				$(this).addClass('Lightbox');
			css = '';
			$(this).children('img').each(function()
			{
				css = $(this).attr('class');
			});
			if(css!='')
				$(this).addClass(css);
		}
	});
	$('#content a.Lightbox').lightBox();
	
	//LOADING POPUP
	//Click the button event!
	if($("#outil_contact").length>0)
	{
		$('body').append('<div id="envoi_ami_background" style="display:none;"></div>');
		
		$("#outil_contact").click(function(){
			//centering with css
			centerPopup();
			//load popup
			loadPopup();
			return false;
		});
	
		/* Formulaire ami popup */
		//Click the x event!
		$("#envoi_ami_close").click(function(){
			disablePopup();
		});
		//Click out event!
		$("#envoi_ami_background").click(function(){
			disablePopup();
		});
		//Press Escape event!
		$(document).keypress(function(e){
			if(e.keyCode==27 && popupStatus==1){
				disablePopup();
			}
		});
		//Message ouvert au chargement de la page (apres une action user)
		if($('#envoi_ami_show_onload').length>0)
		{
			$("#outil_contact").click();
		}
	}
	
	if($('.diaporama').length>0)
		$('.diaporama').slideShow();
	
	/*Share btn, lent */
	$('#addthis_button').append('<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4b701fe333c616a0"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b701fe333c616a0"></script>');

});

/* Captacha theme */
var RecaptchaOptions = {
	lang : 'fr',
	theme : 'white'
};
