/*
 * Modernizr v1.6
 * http://www.modernizr.com
 *
 * Developed by: 
 * - Faruk Ates  http://farukat.es/
 * - Paul Irish  http://paulirish.com/
 *
 * Copyright (c) 2009-2010
 * Dual-licensed under the BSD or MIT licenses.
 * http://www.modernizr.com/license/
 */
window.Modernizr=function(i,e,u){function s(a,b){return(""+a).indexOf(b)!==-1}function D(a,b){for(var c in a)if(j[a[c]]!==u&&(!b||b(a[c],E)))return true}function n(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1);c=(a+" "+F.join(c+" ")+c).split(" ");return!!D(c,b)}function S(){f.input=function(a){for(var b=0,c=a.length;b<c;b++)L[a[b]]=!!(a[b]in h);return L}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" "));f.inputtypes=function(a){for(var b=0,c,k=a.length;b<
k;b++){h.setAttribute("type",a[b]);if(c=h.type!=="text"){h.value=M;if(/^range$/.test(h.type)&&h.style.WebkitAppearance!==u){l.appendChild(h);c=e.defaultView;c=c.getComputedStyle&&c.getComputedStyle(h,null).WebkitAppearance!=="textfield"&&h.offsetHeight!==0;l.removeChild(h)}else/^(search|tel)$/.test(h.type)||(c=/^(url|email)$/.test(h.type)?h.checkValidity&&h.checkValidity()===false:h.value!=M)}N[a[b]]=!!c}return N}("search tel url email datetime date month week time datetime-local number range color".split(" "))}
var f={},l=e.documentElement,E=e.createElement("modernizr"),j=E.style,h=e.createElement("input"),M=":)",O=Object.prototype.toString,q=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),F="Webkit Moz O ms Khtml".split(" "),v={svg:"http://www.w3.org/2000/svg"},d={},N={},L={},P=[],w,Q=function(a){var b=document.createElement("style"),c=e.createElement("div");b.textContent=a+"{#modernizr{height:3px}}";(e.head||e.getElementsByTagName("head")[0]).appendChild(b);c.id="modernizr";l.appendChild(c);a=c.offsetHeight===
3;b.parentNode.removeChild(b);c.parentNode.removeChild(c);return!!a},o=function(){var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return function(b,c){c=c||document.createElement(a[b]||"div");b="on"+b;var k=b in c;if(!k){c.setAttribute||(c=document.createElement("div"));if(c.setAttribute&&c.removeAttribute){c.setAttribute(b,"");k=typeof c[b]=="function";if(typeof c[b]!="undefined")c[b]=u;c.removeAttribute(b)}}return k}}(),G={}.hasOwnProperty,R;R=
typeof G!=="undefined"&&typeof G.call!=="undefined"?function(a,b){return G.call(a,b)}:function(a,b){return b in a&&typeof a.constructor.prototype[b]==="undefined"};d.flexbox=function(){var a=e.createElement("div"),b=e.createElement("div");(function(k,g,r,x){g+=":";k.style.cssText=(g+q.join(r+";"+g)).slice(0,-g.length)+(x||"")})(a,"display","box","width:42px;padding:0;");b.style.cssText=q.join("box-flex:1;")+"width:10px;";a.appendChild(b);l.appendChild(a);var c=b.offsetWidth===42;a.removeChild(b);
l.removeChild(a);return c};d.canvas=function(){var a=e.createElement("canvas");return!!(a.getContext&&a.getContext("2d"))};d.canvastext=function(){return!!(f.canvas&&typeof e.createElement("canvas").getContext("2d").fillText=="function")};d.webgl=function(){var a=e.createElement("canvas");try{if(a.getContext("webgl"))return true}catch(b){}try{if(a.getContext("experimental-webgl"))return true}catch(c){}return false};d.touch=function(){return"ontouchstart"in i||Q("@media ("+q.join("touch-enabled),(")+
"modernizr)")};d.geolocation=function(){return!!navigator.geolocation};d.postmessage=function(){return!!i.postMessage};d.websqldatabase=function(){return!!i.openDatabase};d.indexedDB=function(){for(var a=-1,b=F.length;++a<b;){var c=F[a].toLowerCase();if(i[c+"_indexedDB"]||i[c+"IndexedDB"])return true}return false};d.hashchange=function(){return o("hashchange",i)&&(document.documentMode===u||document.documentMode>7)};d.history=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return o("drag")&&
o("dragstart")&&o("dragenter")&&o("dragover")&&o("dragleave")&&o("dragend")&&o("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){j.cssText="background-color:rgba(150,255,150,.5)";return s(j.backgroundColor,"rgba")};d.hsla=function(){j.cssText="background-color:hsla(120,40%,100%,.5)";return s(j.backgroundColor,"rgba")||s(j.backgroundColor,"hsla")};d.multiplebgs=function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)};d.backgroundsize=
function(){return n("backgroundSize")};d.borderimage=function(){return n("borderImage")};d.borderradius=function(){return n("borderRadius","",function(a){return s(a,"orderRadius")})};d.boxshadow=function(){return n("boxShadow")};d.textshadow=function(){return e.createElement("div").style.textShadow===""};d.opacity=function(){var a=q.join("opacity:.5;")+"";j.cssText=a;return s(j.opacity,"0.5")};d.cssanimations=function(){return n("animationName")};d.csscolumns=function(){return n("columnCount")};d.cssgradients=
function(){var a=("background-image:"+q.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+q.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);j.cssText=a;return s(j.backgroundImage,"gradient")};d.cssreflections=function(){return n("boxReflect")};d.csstransforms=function(){return!!D(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!D(["perspectiveProperty","WebkitPerspective",
"MozPerspective","OPerspective","msPerspective"]);if(a)a=Q("@media ("+q.join("transform-3d),(")+"modernizr)");return a};d.csstransitions=function(){return n("transitionProperty")};d.fontface=function(){var a,b=e.head||e.getElementsByTagName("head")[0]||l,c=e.createElement("style"),k=e.implementation||{hasFeature:function(){return false}};c.type="text/css";b.insertBefore(c,b.firstChild);a=c.sheet||c.styleSheet;b=k.hasFeature("CSS2","")?function(g){if(!(a&&g))return false;var r=false;try{a.insertRule(g,
0);r=!/unknown/i.test(a.cssRules[0].cssText);a.deleteRule(a.cssRules.length-1)}catch(x){}return r}:function(g){if(!(a&&g))return false;a.cssText=g;return a.cssText.length!==0&&!/unknown/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(g.split(" ")[0])===0};f._fontfaceready=function(g){g(f.fontface)};return b('@font-face { font-family: "font"; src: "font.ttf"; }')};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"');
b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"')||a.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b};d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localstorage=function(){try{return"localStorage"in
i&&i.localStorage!==null}catch(a){return false}};d.sessionstorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webWorkers=function(){return!!i.Worker};d.applicationcache=function(){return!!i.applicationCache};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS(v.svg,"svg").createSVGRect};d.inlinesvg=function(){var a=document.createElement("div");a.innerHTML="<svg/>";return(a.firstChild&&a.firstChild.namespaceURI)==v.svg};d.smil=function(){return!!e.createElementNS&&
/SVG/.test(O.call(e.createElementNS(v.svg,"animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(O.call(e.createElementNS(v.svg,"clipPath")))};for(var H in d)if(R(d,H)){w=H.toLowerCase();f[w]=d[H]();P.push((f[w]?"":"no-")+w)}f.input||S();f.crosswindowmessaging=f.postmessage;f.historymanagement=f.history;f.addTest=function(a,b){a=a.toLowerCase();if(!f[a]){b=!!b();l.className+=" "+(b?"":"no-")+a;f[a]=b;return f}};j.cssText="";E=h=null;i.attachEvent&&function(){var a=e.createElement("div");
a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function c(p){for(var m=-1;++m<r;)p.createElement(g[m])}function k(p,m){for(var I=p.length,t=-1,y,J=[];++t<I;){y=p[t];m=y.media||m;J.push(k(y.imports,m));J.push(y.cssText)}return J.join("")}var g="abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video".split("|"),r=g.length,x=RegExp("<(/*)(abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video)",
"gi"),T=RegExp("\\b(abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video)\\b(?!.*[;}])","gi"),z=b.createDocumentFragment(),A=b.documentElement,K=A.firstChild,B=b.createElement("style"),C=b.createElement("body");B.media="all";c(b);c(z);a.attachEvent("onbeforeprint",function(){for(var p=-1;++p<r;)for(var m=b.getElementsByTagName(g[p]),I=m.length,t=-1;++t<I;)if(m[t].className.indexOf("iepp_")<0)m[t].className+=" iepp_"+
g[p];K.insertBefore(B,K.firstChild);B.styleSheet.cssText=k(b.styleSheets,"all").replace(T,".iepp_$1");z.appendChild(b.body);A.appendChild(C);C.innerHTML=z.firstChild.innerHTML.replace(x,"<$1bdo")});a.attachEvent("onafterprint",function(){C.innerHTML="";A.removeChild(C);K.removeChild(B);A.appendChild(z.firstChild)})}(this,document);f._enableHTML5=true;f._version="1.6";l.className=l.className.replace(/\bno-js\b/,"")+" js";l.className+=" "+P.join(" ");return f}(this,this.document);;
/**
 * Fichier : affichage.js
 * Description : fonctions JS spécifiques à
 * la présentation du site
 * Auteur : Hamza Iqbal - hiqbal[at]actualys.com
 * Copyright: Actualys
 ******************************************/

/**
 * Initialisation
 ******************************************/
jQuery(document).ready( function($)
{
	// Corectifs IE
	if($.browser.msie)
	{
		try
		{
			/**
			 * PNG fix
			 ******************************************/
			if(typeof DD_belatedPNG.fix == 'function' && parseInt($.browser.version) <= 6)
				DD_belatedPNG.fix('.pngfix');
		}
		catch(e) {}
	}
});;
/**
 * Fichier : global.js
 * Description : fonctions JS génériques
 * Auteur : Hamza Iqbal - hiqbal[at]actualys.com
 * Copyright: Actualys
 ******************************************/

/**
 * Initialisation
 ******************************************/
(function($)
{
	$.oz = $.oz || {};

	$(document).ready( function()
	{
		$.detectTerminal();
		$.survolHeader();
		$.videInputFocus();
		$('img.rollover').survolImg();
		
		// Fonctions spécifiques à la page d'accueil
		if ($('#home_page').size())
		{
			$.carrouselAccueil();
			$.expertsHome();
			$.fanTextHome();
			$.quickFlipAccueil();//quatre functions à cause de problemes sur ie 7			
			
			$('#home_page form .main_button').click(function() {
				$(this).parents('form').submit();
				return false;
			}).parents('form').submit(function() {
				if (!$('#mail_news').data('changed')) {
					$('#mail_news').val('');
				}
				
				if (!/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test($('#mail_news').val())) {
					alert(Drupal.t("This address appears to be incorrect"));
					$('#mail_news').focus();
					return false;
				}
			});
			
			$('#mail_news').focus(function() {
				if (!$(this).data('changed')) {
					$(this).val('');
					$(this).data('changed', true);
				}
			});
		}
		if ($('#our_team').size())
		{
			$.hoverTeam();
		}
		if ($('#our_publications').size())
		{
			$.carrouselPublications();
		}
		if ($('#your_projects').size())
		{
			$.switchDeployProject();
		}
		if ($('#subscribe_events').size())
		{
			$.toggleFormEventSubscription();
		}
		
		if ($('#timeline').length)
		{
			$.oz.timeline();
		}
		
		if ($('.node-person').length)
		{
			$('.node-person .cv_tooltip').each(function(k,v) {
				$(v).css('width', ($('.cv_tooltip_center', v).width()+15 + 11*2) + "px");
			});
		}
		
		$('#service_lab .see_more').click(function() {
			var detail = $(this).parents('.servicelab_content').find('.more');
			
			if ($(this).hasClass('see_more_on')) {
				$(this).removeClass('see_more_on');
				$('span', this).text(Drupal.t('Read more'));
				detail.slideUp();
			}
			else {
				$(this).addClass('see_more_on');
				$('span', this).text(Drupal.t('Close'));
				detail.slideDown();
			}
		});
	});
	
	/**
	 * Slider timeline
	 ******************************************/
	
	$.oz.timeline = function() {
		$("#timeline").carouFredSel({
				width: 572,
				height: 177,
				auto: false,
				infinite:false,
				circular:false,
				items: {
					visible: 4,
					minimum: 4,
					width: 143,
					start: true
				},
				scroll: {
					items: 4,
					easing: "linear"
				},
				next: {
					button: "#next"
				},
				prev: {
					button: "#prev"
				}
			}); 

		$("#timeline .date").click(function() {
			$(this).addClass("selected").siblings().removeClass("selected").find('.hover').fadeTo('fast', 0);
			
			$("#caption").hide();
			$("#caption").html($(this).find('.date-caption').html()).fadeIn();
		});
		
		$("#timeline .image").hover(function() {
			if ($(this).parents('.date').hasClass('selected')) return;
			
			$('.hover', this).stop().fadeTo('fast', 1);
		}, function() {
			if ($(this).parents('.date').hasClass('selected')) return;
		
			$('.hover', this).stop().fadeOut('fast', 0);
		}).find('.hover').fadeOut();
		
		$("#timeline .image").eq(0).click();
	};
	
	
	/**
	 * Var dump
	 ******************************************/
	$.varDump = function(arr,level)
	{
		var dumped_text = "";
		if(!level) level = 0;
		
		//The padding given at the beginning of the line.
		var level_padding = "";
		for(var j=0;j<level+1;j++) level_padding += "    ";
		
		if(typeof(arr) == 'object') { //Array/Hashes/Objects 
			for(var item in arr) {
				var value = arr[item];
				
				if(typeof(value) == 'object') { //If it is an array,
					dumped_text += level_padding + "'" + item + "' ...\n";
					dumped_text += $.varDump(value,level+1);
				} else {
					dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
				}
			}
		} else { //Stings/Chars/Numbers etc.
			dumped_text = "===> "+arr+" <=== ("+typeof(arr)+")";
		}
		console.log(dumped_text);
	};
	
	/**
	 * Sort aléatoirement un tableau
	 * $.shuffleTab(tableau);
	 ******************************************/
	$.shuffleTab = function(arr)
	{
		for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
		return arr;
	};
	
	/**
	 * Transforme une chaîne de caractères en objet JS
	 * $.unserialize(s);
	 ******************************************/
	$.unserialize = function(s)
	{
	 	var s = decodeURI(s).split("&");
		var param;
		var paramsTab = {};
		
		$.each(s, function()
		{
			param = this.split("=");
			paramsTab[param[0]] = param[1];
        });
		
        return paramsTab;
    };
	
	/**
	 * Transforme une chaîne de caractères en objet JS
	 * $.detectTerminal();
	 ******************************************/
	$.detectTerminal = function()
	{
		var terminalAgent = navigator.userAgent.toLowerCase();
		var agentID = terminalAgent.match(/(iphone|ipod|ipad|android)/);
		var terminal = '';
		var version;
		
		if(agentID)
		{
			if(agentID.indexOf('iphone') >= 0) terminal = 'iphone';
			else if(agentID.indexOf('ipod') >=0 ) terminal = 'ipod';
			else if(agentID.indexOf('ipad') >= 0) terminal = 'ipad';
			else if(agentID.indexOf('android') >= 0) terminal = 'android';
		}
		else
		{
			version = parseInt($.browser.version);
			
			if($.browser.webkit) terminal = 'webkit';
			else if($.browser.mozilla) terminal = 'mozilla';
			else if($.browser.opera) terminal = 'opera';
			else if($.browser.msie)
			{
				if(version == 6) terminal = 'msie6';
				else if(version == 7) terminal = 'msie7';
				else if(version == 8) terminal = 'msie8';
				else if(version == 9) terminal = 'msie9';
			}
		}
		
		$('body').addClass(terminal);
		return terminal;
	};
	
	/**
	 * Gère le remplacement d'image au survol
	 * $(s).survolImg({suffixe: '_on'});
	 ******************************************/
	$.fn.survolImg = function(opt)
	{
		var images = $(this);
		var options = { suffixe: '_on' };
		if(opt) options = $.extend(options, opt);
		
		images.prechargeSurvolImg(options.suffixe);
		
		images.hover
		(
			function () {$(this).attr( 'src', survolCheminImg('survol', $(this).attr('src'), options.suffixe) );}, 
			function () {$(this).attr( 'src', survolCheminImg('', $(this).attr('src'), options.suffixe) );}
		);
	};
	 
	$.fn.prechargeSurvolImg = function(suffixe)
	{
		var images = $(this);
		
		$(window).bind('load', function()
		{
			images.each( function()
			{
				$('<img>').attr( 'src', survolCheminImg('survol', $(this).attr('src'), suffixe) );
			});
		});
	}
	
	var survolCheminImg = function(etat, src, suffixe)
	{
		if(etat == 'survol')
			return src.substring(0, src.search(/(\.[a-z]+)$/) ) + suffixe + src.match(/(\.[a-z]+)$/)[0]; 
		else
			return src.replace(suffixe+'.', '.');	
	}
	
	/**
	 * Vide la valeur des champs input au focus
	 * $.videInputFocus();
	 ******************************************/
	$.videInputFocus = function(opt)
	{	        
        if ((window.location.pathname == '/fr/contact' || window.location.pathname == '/en/contact-us'
        || window.location.pathname == '/fr/les-rencontres-a-venir') && /MSIE (\d+\.\d+);/.test(navigator.userAgent)) return;
            
		if(!Modernizr.input.placeholder)
		{
			var input = $('input[placeholder!=""][value=""][type="text"]');
			
			input.each(function()
			{
				var placeholder = $(this).attr('placeholder');
				$(this).val(placeholder);
				
				$(this).focus( function() { if($(this).val() == placeholder) $(this).val(''); });	
				$(this).blur( function() { if($(this).val() == '') $(this).val(placeholder); });
			});
		}
        
	};
	
	/**
	 * Rollover d'un élément
	 * $(s).survolElem
		({
			classe: 'hover',
			ie6: false
		});
	 ******************************************/
	$.fn.survolElem = function(opt)
	{
		var elem = $(this);
		
		var options =
		{
			classe: 'hover',
			ie6: false
		};
		
		if(opt) options = $.extend(options, opt);
		
		if(options.ie6 && !($.browser.msie && parseInt($.browser.version) == 6)) return false;
		
		elem.hover
		(
			function () { $(this).addClass(options.classe); }, 
			function () { $(this).removeClass(options.classe); }
		);
	};
	
	/**
	 * Blocs de même hauteur
	 * $(s).hauteurEgale();
	 ******************************************/
	$.fn.hauteurEgale = function()
	{
		var blocs = $(this);
		var hauteurMax = 0;
		
		blocs.height('auto');
		blocs.each(function()
		{
			var hauteur = $(this).height();
			if(hauteur > hauteurMax) hauteurMax = hauteur;
		});
		blocs.height(hauteurMax);
	};
	
	/**
	 * Blocs de même largeur
	 * $(s).largeurEgale();
	 ******************************************/
	$.fn.largeurEgale = function()
	{
		var blocs = $(this);
		var largeurMax = 0;
		
		blocs.each(function()
		{
			var largeur = $(this).width();
			if(largeur > largeurMax) largeurMax = largeur;
		});
		blocs.width(largeurMax);
	};
	
	
	/**
	 * Affiche / Masque plus de texte
	 * $(s).voirPlus
		({
			contenu: '.plus',
			lien: '.voir_plus',
			lien_ouvert: '.voir_plus_on',
			vitesse: '',
			callback: function() {}
		});
	 ******************************************/
	$.fn.voirPlus = function(opt) 
	{
		var blocs = $(this);
		
		var options =
		{
			contenu: '.plus',
			lien: '.voir_plus',
			lien_ouvert: '.voir_plus_on',
			vitesse: '',
			callback: function() {}
		};
		
		if(opt) options = $.extend(options, opt);
		
		blocs.each(function()
		{
			var bloc = $(this);
			var contenu = bloc.find('.'+options.contenu);
			var lien = bloc.find('a.'+options.lien);
	
			contenu.hide();
			
			lien.click(function()
			{
				contenu.slideToggle(options.vitesse, function(){ options.callback(); });
				lien.toggleClass(options.lien_ouvert);
				return false;
			});
		});
	}
	
	
	/**
	 * Retourne les paramètres d'une URL
	 * URL de la page par défaut
	 * $.getURLParam(url);
	 ******************************************/
	$.getURLParam = function(url) 
	{
		if(!url) url = window.location.href;
		
		url = url.split('?');
		
		var paramsTab = {};
		var params, param;
		var domaine = false;
		
		// Si un nom de domaine est défini
		if(url[1])
		{
			domaine = true;
			params = url[1];
		}
		// S'il n'y a que des paramètres
		else params = url[0];
		
		// Construction de l'objet
		paramsTab = $.unserialize(params);
		if(domaine) paramsTab['domaine'] = url[0];
		
		return paramsTab;
	};
	
	/**
	 * Met à jour une URL avec des nouveaux 
	 * paramètres
	 * $.setURLParam(url, {nom1: val1, nom2: val2, ... });
	 ******************************************/
	$.setURLParam = function(url, nouvParams) 
	{
		var paramsTab = $.getURLParam(url);
		var nouvUrl = '';
		var domaine = false;
		var param;
		var premierParam = true;
		
		// fusionne les anciens et les nouveaux paramètres
		$.extend(paramsTab, nouvParams);
		
		for(param in paramsTab)
		{
			// Si un nom de domaine est défini
			if(param == 'domaine') domaine = paramsTab[param];
			
			// Sinon construction de l'URL avec les paramètres
			else
			{
				// ajoute '&' avant chaque paramètre sauf le 1er 
				if(!premierParam) nouvUrl += '&';
				premierParam = false;
				
				nouvUrl += param + '=' + paramsTab[param];
			}
		}
		// ajoute le domaine aux paramètres
		if(domaine) nouvUrl = domaine + '?' + nouvUrl;

		return nouvUrl;
	};
	
	$.survolHeader = function()
	{
		var liensHeader = $("div#header_nav ul li a");
		
		liensHeader.each(function()
		{
			var lien = $(this);
			var marginTop = lien.css('marginTop');
			
			lien.hover(function()
			{
				lien.animate({'marginTop': 0}, 300);
			},function()
			{
				lien.animate({'marginTop': marginTop}, 300);
			});
		});
	};
	
	/**
	 * Initialise le carrousel de la page d'accueil
	 * $.carrouselAccueil();
	 ******************************************/
	$.carrouselAccueil = function()
	{
		var carrouselAccueil = $("#carrousel_home");
		
		$(carrouselAccueil).jcarousel(
		{
        	scroll: 1,
			visible: 1,
			initCallback: $.carrouselAccueilControles,
			buttonNextHTML: null,
			buttonPrevHTML: null
    	});
	};
	
	/**
	 * Crée les contrôles du carrousel de la page d'accueil
	 * $.carrouselAccueilControles();
	 ******************************************/
	$.carrouselAccueilControles = function(carrousel)
	{
		var carrouselControles = $('#carrousel_control li');
		
		carrouselControles.filter(':first').addClass('actif');
		
		carrouselControles.children().bind('click', function()
		{
			var lien = $(this);
			var parent = lien.parent();
			var etape = parseInt(lien.text());
			
			carrouselControles.removeClass('actif');
        	carrousel.scroll($.jcarousel.intval(etape));
			parent.addClass('actif');
					
        	return false;
    	});
	};
	
	/**
	 * Initialise l'affichage des vignette des experts de la page d'accueil
	 * $.expertsAccueil();
	 ******************************************/
	$.expertsHome = function()
	{
		var expertsList = $('#list_experts ul.nos_experts li');
		var expSpeed = 5000;
		var expertsArrayShuffled = {};
		var remainingExpertsArray = [];
		var currentItem;
		var itemsLength;
		var currentExpert;
		
		
		var expertsArray = [];
		$('.nos_experts > li').each(function() {
			var exp = {
				src: $("img", this).attr('src'),
				job: $("h4", this).text(),
				identity: $("h3", this).text()
			};
			
			expertsArray.push(exp);
		});
		
		if (expertsArray.length < 9) return;
		
		// Gets the shuffled array
		expertsArrayShuffled = $.shuffleTab(expertsArray);
		
		$.each(expertsArrayShuffled, function(i, expert)
		{
			// Gets the first nine items and fills the HTML list
			if(i < 9)
			{
				var expertLi = expertsList.eq(i);
				expertLi.find('img').attr('src', expert.src);
				
				expertLi.find('h3').text(expert.identity);
				expertLi.find('h4').text(expert.job);
				
			}
			// Puts the remaining items in a new Array
			else
			{
				remainingExpertsArray.push(expert);
			}
		});
		
		
		// Sets the next item that will be displayed
		currentItem = 0;
		itemsLength = remainingExpertsArray.length -1;
		currentExpert = remainingExpertsArray[currentItem];
		
		upExpert();
		
		function upExpert ()
		{
			
			setTimeout(switchExpert, expSpeed);
			
		};
		
		// Changes the attributes of the middle item
		function switchExpert()
		{
			var caseRandomExpert = parseInt(Math.random() * 9);
			var expertToChange = expertsList.eq(caseRandomExpert);
			var expertToChangeImg = expertToChange.find('img');
			var expertToChangeH3 = expertToChange.find('h3');
			var expertToChangeH4 = expertToChange.find('h4');
			
			var expertToChangeArray = {
				src : expertToChangeImg.attr('src'),
				identity : expertToChangeH3.text(),
				job : expertToChangeH4.text()
			};
										
			expertToChange.fadeTo("slow",0.5,function(){
				$(this).fadeTo("slow",1);
			});
			
			expertToChangeImg.attr('src', currentExpert.src);
			expertToChangeH3.text(currentExpert.identity);
			expertToChangeH4.text(currentExpert.job);
			
			currentExpert.src = expertToChangeArray.src;
			currentExpert.identity = expertToChangeArray.identity;
			currentExpert.job = expertToChangeArray.job;
			
			currentItem == itemsLength ? currentItem = 0 : currentItem++;
			
			currentExpert = remainingExpertsArray[currentItem];
			
			upExpert();
		};
	};
	
	/**
	 * Initialise l'affichage des vignette en eventail
	 * $.fanTextHome();
	 ******************************************/
	$.fanTextHome = function()
	{
		var blocContentFan = $(".block_content_shadow.bcs_img");//bloc parent
		var contentFan = $(".bcs_img .visual");//la div avec l'image
		
		var imgContentFan = contentFan.find("img");
		imgContentFan.survolImg({suffixe: '_on'});//différente image au survol
		
		contentFan.each(
		function(){
			$(this).hover(
			function(){
				$(this).addClass("hovered");
				$(this).siblings().removeClass("hovered");
			},
			function(){
				$(this).removeClass("hovered");
			});
		})
	}
    
    $.quickFlipAccueil = function()
    {
        var carrousel = $('#carrousel_home');
        var classSuffixes = ['','_2','_3','_4'];
        
        var cssFlip = [
             {'width':'207px','height':'189px'},
             {'width':'214px','height':'189px'},
             {'width':'239px','height':'189px'},
             {'width':'189px','height':'189px'}
        ];
        
        var configQF =
        {
            closeSpeed : 100,
            openSpeed : 100
        }
        
        $.each(classSuffixes, function(n, cs)
        {
            var flipContener = carrousel.find('.quick_flip' + cs);
            flipContener.css(cssFlip[n]);
            
            flipContener.quickFlip(configQF);
            flipContener.hover
            (
                function() { $(this).quickFlipper(); },
                function(){ $(this).quickFlipper(); }
            );
        });
    };	    	
	
	/**
	 * Initialise l'affichage des vignette des experts de la page d'accueil
	 * $.expertsAccueil();
	 ******************************************/
	$.hoverTeam = function()
	{
		//$('#our_team .team_member').hauteurEgale();
		
		var contentTeam = $('#our_team');
		var teamMembers = contentTeam.find('.team_member');
		
		teamMembers.each(function()
		{
			var member = $(this);
			var memberImg = member.find('.img');
			var member_bcs = member.find('.block_content_shadow');
			var bcs_top = member_bcs.css('top');
			var bcs_top_hover = 0;
			var bcs_left = member_bcs.css('left');
			var bcs_left_hover = 0;
			var bcs_width = member_bcs.css('width');
			var bcs_width_hover = 209;
			
			member.hover
			(
				function ()
				{
					member_bcs.stop().animate({top: bcs_top_hover, left: bcs_left_hover, width: bcs_width_hover},1);
					memberImg.find('.default').hide();
					memberImg.find('.hover').show();
				}, 
				function ()
				{
					member_bcs.stop().animate({top: bcs_top, left: bcs_left, width: bcs_width}, 1);
					memberImg.find('.hover').hide();
					memberImg.find('.default').show();
				} 
			);
		});
		
	};
	
	/**
	 * Initialise le carrousel de la page nos publications
	 * $.carrouselPublications();
	 ******************************************/
	$.carrouselPublications = function()
	{
		var carrouselPublications = $("#carrousel_publications_list");
		var publications = carrouselPublications.find("li.publication");
		var publicationContents = $('#our_publications .publication_content');
		
		publications.filter(':first').addClass('current');
		publicationContents.filter(':first').show();
		
		publications.children().bind('click', function()
		{
			var publicationLink = $(this);
			var parent = publicationLink.parent();
			var idPublicationToShow = publicationLink.attr('href');
			
			publications.removeClass('current');
			parent.addClass('current');
			
			publicationContents.hide();
			$(idPublicationToShow).show();
			
			return false;
		});
		
		carrouselPublications.jcarousel(
		{
        	scroll: 1,
			visible: 3	
    	});
		
	};
	
	/**
	  * Initialise le changement de la page déployer vos projets
	 * $.switchDeployProject();
	 ******************************************/
	$.switchDeployProject = function()
	{
		var switchDeployProject = $("#carrousel_projects_list");
		var projects = switchDeployProject.find("li.project");
		var projectContent = $('#your_projects .project_content');
		
		projectContent.hide();
		projectContent.filter(':first').show();

		projects.find('a').bind('click', function()
		{
			var projectLink = $(this);
			var parent = projectLink.parents('li.project');
			var idProjectToShow = projectLink.attr('href');
			
			projects.removeClass('current');
			parent.addClass('current');
			
			projectContent.hide();
			$(idProjectToShow).show();
			
			return false;
		});
		
		projects.filter(':first').find('a').eq(0).click();
	};
	
	/**
	  * Affiche le formulaire caché
	 * $.toggleFormEventSubscription();
	 ******************************************/
	$.toggleFormEventSubscription = function()
	{
		// rewrite by Bao Nguyen
		$('.diary_event').each(function() {
			var eventSubscription = $('.event_subscription', this);
			var btnSeeMore = $('.see_more', this);
			
			btnSeeMore.click(function() {
				if (btnSeeMore.hasClass('see_more_on'))
				{
					btnSeeMore.removeClass('see_more_on').text(Drupal.t('Register for the conference'));
					eventSubscription.slideUp();
				}
				else
				{
					btnSeeMore.addClass('see_more_on').text(Drupal.t('Close'));
					eventSubscription.slideDown();
				}
				
				return false;
			});
		});
	};
	
})(jQuery);;

