var userProfile;
var tweetBox_json;

$(document).ready(function() {
    userProfile = 'MotionInDesign' ;
    tweetBox_json = new Object;
    tweetBox_json.tweets = new Array();
	
	$('div.header div.slidersTop div.contact div.form div.postulez input.parcourir').change(function(e){
		$('div.header div.slidersTop div.contact div.form div.postulez #parcourirSup').text($(this).val());
	});
	
}) ;

$(function()
{
	/************************/
	/******** COMMUN ********/
	/************************/
	
	/******** Gestion des sliders du header ********/
	var sliderOuvert = '';
	var transitionSlider = false;
	
	$('div.header div.boutons a').click(function(){
		if(transitionSlider == false)
		{
			transitionSlider = true;
			var sliderAOuvrir = $('div.header div.slidersTop div.'+$(this)[0].className);
			// si aucun slider n'est ouvert
			if(sliderOuvert == '') {
				sliderAOuvrir.css('z-index', '2');
				hautSliderTop = 446-446-sliderAOuvrir.height();
				$(window).trigger('scroll');
				$('div.header').animate({
					'margin-top' : sliderAOuvrir.height()-446
				}, 500, 'easeOutExpo', function(){
					sliderOuvert = sliderAOuvrir;
					transitionSlider = false;
				});
			}
			// si le bouton cliqué correspond au slider ouvert
			else if (sliderAOuvrir[0].className == sliderOuvert[0].className) {
				hautSliderTop = 0;
				$('div.header').animate({
					'margin-top' : -446
				}, 500, 'easeInExpo', function(){
					sliderOuvert.css('z-index', '1');
					$('div.header div.form div.ecrivez').show(0);
					$('div.header div.form div.postulez').hide(0);
					sliderOuvert = '';
					$(window).trigger('scroll');
					transitionSlider = false;
				});
			}
			// si on clique sur un autre onglet alors qu'un slider est ouvert
			else {
				$('div.header').animate({
					'margin-top' : -446
				}, 500, 'easeInExpo', function(){
					sliderOuvert.css('z-index', '1');
					sliderAOuvrir.css('z-index', '2');
					hautSliderTop = 446-446-sliderAOuvrir.height();
					$(window).trigger('scroll');
					$('div.header').animate({
						'margin-top' : sliderAOuvrir.height()-446
					}, 500, 'easeOutExpo');
					$('div.header div.form div.ecrivez').show(0);
					$('div.header div.form div.postulez').hide(0);
					sliderOuvert = sliderAOuvrir;
					transitionSlider = false;
				});
			}
		}
		return false;
	});
	
	/* Fermer le slider ouvert avec la croix */
	$('div.header div.slidersTop div div.fermer').click(function(){
		hautSliderTop = 0;
		$('div.header').animate({
			'margin-top' : -446
		}, 500, 'easeInExpo', function(){
			sliderOuvert.css('z-index', '1');
			sliderOuvert = '';
			$('div.header div.form div.ecrivez').show(0);
			$('div.header div.form div.postulez').hide(0);
			$(window).trigger('scroll');
			transitionSlider = false;
		});
		return false;
	});
	
	
	/* Éléments du formulaire de contact */
	$('div.header div.slidersTop div.contact div.map').width($('body').width()-($('body').width()-970)/2-470-10);
	$('div.header div.slidersTop div.contact div.form').css('margin-right', ($('body').width()-970)/2);
	$('input.uploadFichier').change(function() {
		$('input.texteFichier').val($(this).val());
	});
	
	/* Barres du menu */
	$('div.header div.menu div.barreMenu').width(385+($('body').width()-970)/2);
	$('div.footer div.menu div.barreMenu').width(373+($('body').width()-970)/2);
	
	/* Fixe la taille de la bande du footer si la largeur du body est inférieur à 1020 */
	if($('body').width()<1020) $('div.footer div.bottom').width($('body').width()+10);
	
	
	
	/******** Gestion de l'affichage des formulaires de contact au clic dans le footer ********/
	$('div.footer div.contact div.postulez').click(function(){
		$('div.header div.form div.ecrivez').hide(0);
		$('div.header div.form div.postulez').show(0);
		$('html').scrollTo('div.header', 600, {easing:'easeInOutExpo', onAfter:function(){
			ouvrirContact('postulez');
		}});
		return false;
	});
	$('div.footer div.bottom div.liens a#contactez').click(function(){
		$('div.header div.form div.ecrivez').show(0);
		$('div.header div.form div.postulez').hide(0);
		$('html').scrollTo('div.header', 600, {easing:'easeInOutExpo', onAfter:function(){
			ouvrirContact('ecrivez');
		}});
		return false;
	});
	
	/* Ouvre le slider de Contact pour laisser apparaitre le formulaire voulu */
	function ouvrirContact(formulaire){
		if(transitionSlider == false)
		{
			transitionSlider = true;
			var sliderAOuvrir = $('div.header div.slidersTop div.contact');
			// si aucun slider n'est ouvert
			if(sliderOuvert == '') {
				sliderAOuvrir.css('z-index', '2');
				hautSliderTop = 446-446-sliderAOuvrir.height();
				$(window).trigger('scroll');
				$('div.header').animate({
					'margin-top' : sliderAOuvrir.height()-446
				}, 500, 'easeOutExpo', function(){
					sliderOuvert = sliderAOuvrir;
					transitionSlider = false;
				});
			}
			// si le slider contact est déjà ouvert
			else if (sliderAOuvrir[0].className == sliderOuvert[0].className) {
				transitionSlider = false;
			}
			// si un autre slider est ouvert
			else {
				hautSliderTop = 446-446-sliderAOuvrir.height();
				$(window).trigger('scroll');
				$('div.header').animate({
					'margin-top' : -446
				}, 500, 'easeInExpo', function(){
					sliderOuvert.css('z-index', '1');
					sliderAOuvrir.css('z-index', '2');
					$('div.header').animate({
						'margin-top' : sliderAOuvrir.height()-446
					}, 500, 'easeOutExpo');
					sliderOuvert = sliderAOuvrir;
					transitionSlider = false;
				});
			}
		}
	}
	
	
	/******** Gestion du survol/désurvol des logos Twiiter et Facebook dans le footer ********/
	$('div.footer div.contact div.facebookTwitter a').mouseenter(function(){
		$(this).children('img.over').fadeIn(300, 'easeOutQuad');
		$(this).children('img.normal').fadeOut(300, 'easeOutQuad');
	});
	$('div.footer div.contact div.facebookTwitter a').mouseleave(function(){
		$(this).children('img.normal').fadeIn(300, 'easeInQuad');
		$(this).children('img.over').fadeOut(300, 'easeInQuad');
	});
	
	
	/******** Gestion des vignettes de réalisations ********/
	$('div.realisations a.realisation').mouseenter(function(){
		$(this).children('div.infos').animate({
			'top': 0
		}, 200, 'easeOutExpo');
	});
	$('div.realisations a.realisation').mouseleave(function(){
		$(this).children('div.infos').animate({
			'top': -100
		}, 200, 'easeInExpo');
	});
	
	
	
	/*************************/
	/******** ACCUEIL ********/
	/*************************/
	
	/******** Gestion du primetime de l'accueil ********/
	/* Survol/désurvol des fleches */
	$('div.pageAccueil div.primetime a.flecheGauche').mouseenter(function(){
		$(this).children('img').animate({
			'margin-left': -30
		}, 100, 'easeOutBack');
	});
	$('div.pageAccueil div.primetime a.flecheGauche').mouseleave(function(){
		$(this).children('img').animate({
			'margin-left': -36
		}, 100, 'easeInBack');
	});
	$('div.pageAccueil div.primetime a.flecheDroite').mouseenter(function(){
		$(this).children('img').animate({
			'margin-left': 20
		}, 100, 'easeOutBack');
	});
	$('div.pageAccueil div.primetime a.flecheDroite').mouseleave(function(){
		$(this).children('img').animate({
			'margin-left': 26
		}, 100, 'easeInBack');
	});
	
	/* Survol/désurvol du call to action */
	$('div.pageAccueil div.primetime div.news a.lien').mouseenter(function(){
		$(this).children('div.callToAction').animate({
			'background-color': '#c6efff'
		}, 300, 'easeOutQuad');
		
		$(this).children('div.infos').children('div.conteneurInfos').children('div.normal').children('h2.ligne1').animate({
			'top': '-157'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.normal').children('h2.ligne2').delay(50).animate({
			'top': '-127'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.normal').children('div.voir').delay(100).animate({
			'top': '-92'
		}, 200, 'easeInExpo');
		
		$(this).children('div.infos').children('div.conteneurInfos').children('div.over').children('h2.ligne1').delay(50).animate({
			'top': '0'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.over').children('h2.ligne2').delay(100).animate({
			'top': '30'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.over').children('div.voir').delay(150).animate({
			'top': '65'
		}, 200, 'easeInExpo');
	});
	$('div.pageAccueil div.primetime div.news a.lien').mouseleave(function(){
		$(this).children('div.callToAction').animate({
			'background-color': '#FFF'
		}, 300, 'easeInQuad');
		
		$(this).children('div.infos').children('div.conteneurInfos').children('div.normal').children('h2.ligne1').delay(150).animate({
			'top': '0'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.normal').children('h2.ligne2').delay(100).animate({
			'top': '30'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.normal').children('div.voir').delay(50).animate({
			'top': '65'
		}, 200, 'easeInExpo');
		
		$(this).children('div.infos').children('div.conteneurInfos').children('div.over').children('h2.ligne1').delay(100).animate({
			'top': '157'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.over').children('h2.ligne2').delay(50).animate({
			'top': '187'
		}, 200, 'easeInExpo');
		$(this).children('div.infos').children('div.conteneurInfos').children('div.over').children('div.voir').animate({
			'top': '222'
		}, 200, 'easeInExpo');
	});
	
	/* Défilement des news du primetime de l'accueil */
	var transitionNews = false;
	var nbNews = 0;
	$('div.pageAccueil div.primetime div.news').each(function() { nbNews++; });
	var newsOuverte = 1;
	var newsAOuvrir = 1;
	$('div.pageAccueil div.primetime div#news1').css({
		'z-index': 2,
		'top': 0
	});
	
	$('div.pageAccueil div.primetime .clickzone, div.pageAccueil div.primetime .bande').click(function(){
		
		if(transitionNews == false)
		{
			transitionNews = true;
			newsAOuvrir++;
			if(newsAOuvrir > nbNews) newsAOuvrir = 1;
			$('div.pageAccueil div.primetime div#news'+newsOuverte).css('z-index', 1);
			$('div.pageAccueil div.primetime div#news'+newsAOuvrir).css('z-index', 2);
			$('div.pageAccueil div.primetime div#news'+newsAOuvrir).animate({
				'top': 0
			}, 500, 'easeOutExpo', function(){
				$('div.pageAccueil div.primetime div#news'+newsOuverte).css('top', '-440px');
				newsOuverte = newsAOuvrir;
				transitionNews = false;
			});
		}
		return false;
	
	})
	
	$('div.pageAccueil div.primetime a.flecheDroite').click(function(){
		if(transitionNews == false)
		{
			transitionNews = true;
			newsAOuvrir++;
			if(newsAOuvrir > nbNews) newsAOuvrir = 1;
			$('div.pageAccueil div.primetime div#news'+newsOuverte).css('z-index', 1);
			$('div.pageAccueil div.primetime div#news'+newsAOuvrir).css('z-index', 2);
			$('div.pageAccueil div.primetime div#news'+newsAOuvrir).animate({
				'top': 0
			}, 500, 'easeOutExpo', function(){
				$('div.pageAccueil div.primetime div#news'+newsOuverte).css('top', '-440px');
				newsOuverte = newsAOuvrir;
				transitionNews = false;
			});
		}
		return false;
	});
	$('div.pageAccueil div.primetime a.flecheGauche').click(function(){
		if(transitionNews == false)
		{
			transitionNews = true;
			newsAOuvrir--;
			if(newsAOuvrir == 0) newsAOuvrir = nbNews;
			$('div.pageAccueil div.primetime div#news'+newsOuverte).css('z-index', 1);
			$('div.pageAccueil div.primetime div#news'+newsAOuvrir).css('z-index', 2);
			$('div.pageAccueil div.primetime div#news'+newsAOuvrir).animate({
				'top': 0
			}, 500, 'easeOutExpo', function(){
				$('div.pageAccueil div.primetime div#news'+newsOuverte).css('top', '-440px');
				newsOuverte = newsAOuvrir;
				transitionNews = false;
			});
		}
		return false;
	});
	
	
	/******** Gestion des articles du blogue sur la page d'accueil ********/
	$('div.pageAccueil div.blogue div.articles div.article').each(function() { nbArticles++; });
	$('div.pageAccueil div#article1').css('top', '0px');
	$('div.pageAccueil div.blogue div.navigation img').click(function(){
		var nbCarac = $(this)[0].id.length;
		var monNumBtn = $(this)[0].id.substring(3, nbCarac);
		clearInterval(monTimerArticles);
		changerArticle(monNumBtn);
	});
	/* Change l'article */
	function changerArticle(numArticle) {
		if(transitionArticles == false)
		{
			transitionArticles = true;
			articleAOuvrir = numArticle;
			
			if(articleAOuvrir > nbArticles) articleAOuvrir = 1;
			
			$('div.pageAccueil div.blogue div.articles div#article'+articleOuvert).css('z-index', 1);
			$('div.pageAccueil div.blogue div.articles div#article'+articleAOuvrir).css('z-index', 2);
			$('div.pageAccueil div.blogue div.articles div#article'+articleAOuvrir).animate({
				'top': 0
			}, 300, 'easeOutExpo', function(){
				$('div.pageAccueil div.blogue div.articles div#article'+articleOuvert).css('top', '-170px');
				$('div.pageAccueil div.blogue div.navigation img#nav'+articleOuvert)[0].src = stylesheet_uri+"/images/boutons/point_nav_inactif.png";
				$('div.pageAccueil div.blogue div.navigation img#nav'+articleAOuvrir)[0].src = stylesheet_uri+"/images/boutons/point_nav_actif.png";
				articleOuvert = articleAOuvrir;
				transitionArticles = false;
			});
		}
	}
	
	
	/******** Gestion de la partie services ********/
	/* Survol/desurvol des chiffres */
	$('div.pageAccueil div.services a.grille div.numeros div').mouseenter(function(){
		$(this).children('img.over').fadeIn(300, 'easeOutQuad');
		$('div.pageAccueil div.services a.grille div.listeServices div#normal').css('display', 'none');
		$('div.pageAccueil div.services a.grille div.listeServices div#'+$(this)[0].className).css('display', 'block');
	});
	$('div.pageAccueil div.services a.grille div.numeros div').mouseleave(function(){
		$(this).children('img.over').fadeOut(300, 'easeInQuad');
		$('div.pageAccueil div.services a.grille div.listeServices div#'+$(this)[0].className).css('display', 'none');
		$('div.pageAccueil div.services a.grille div.listeServices div#normal').css('display', 'block');
	});
	
	
	
	/******************************/
	/******** RÉALISATIONS ********/
	/******************************/
	
	/******** Gestion de la box Toutes les réalisations ********/
	$('div.pageAccueil div.realisations a.toutesReas').mouseenter(function(){
		$(this).animate({
			'background-color': '#c6efff'
		}, 300, 'easeOutQuad');
		$(this).children('div.conteneurInfos').children('div.normal').children('div.ligne1').animate({
			'top': '-105'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.normal').children('div.ligne2').delay(50).animate({
			'top': '-76'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.normal').children('div.ligne3').delay(100).animate({
			'top': '-47'
		}, 200, 'easeInExpo');
		
		$(this).children('div.conteneurInfos').children('div.over').children('div.ligne1').delay(50).animate({
			'top': '95'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.over').children('div.ligne2').delay(100).animate({
			'top': '124'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.over').children('div.ligne3').delay(150).animate({
			'top': '153'
		}, 200, 'easeInExpo');
	});
	$('div.pageAccueil div.realisations a.toutesReas').mouseleave(function(){
		$(this).animate({
			'background-color': '#fbfbfb'
		}, 300, 'easeInQuad');
		$(this).children('div.conteneurInfos').children('div.normal').children('div.ligne1').delay(150).animate({
			'top': '95'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.normal').children('div.ligne2').delay(100).animate({
			'top': '124'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.normal').children('div.ligne3').delay(50).animate({
			'top': '153'
		}, 200, 'easeInExpo');
		
		$(this).children('div.conteneurInfos').children('div.over').children('div.ligne1').delay(100).animate({
			'top': '295'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.over').children('div.ligne2').delay(50).animate({
			'top': '324'
		}, 200, 'easeInExpo');
		$(this).children('div.conteneurInfos').children('div.over').children('div.ligne3').animate({
			'top': '353'
		}, 200, 'easeInExpo');
	});
	
	
	/******** Gestion du titre de la page d'une réalisation ********/
	$('div.pageRealisation h1.titrePage').mouseenter(function(){
		$(this).children('div.ligne1').children('div.titreProjet').animate({
			'color': '#009ddc'
		}, 200, 'easeOutExpo');
		$(this).children('div.ligne1').children('div.fleche').children('img.over').fadeIn(200, 'easeOutQuad');
		$(this).children('div.ligne1').children('div.fleche').children('img.normal').fadeOut(200, 'easeOutQuad');
		$(this).children('div.conteneurLigne2').children('div.ligne2').animate({
			'top': '-7px'
		}, 200, 'easeOutExpo');
	});
	$('div.pageRealisation h1.titrePage').mouseleave(function(){
		$(this).children('div.ligne1').children('div.titreProjet').animate({
			'color': '#000'
		}, 200, 'easeInExpo');
		$(this).children('div.ligne1').children('div.fleche').children('img.normal').fadeIn(200, 'easeInQuad');
		$(this).children('div.ligne1').children('div.fleche').children('img.over').fadeOut(200, 'easeInQuad');
		$('div.pageRealisation h1.titrePage div.ligne2').animate({
			'top': '-73px'
		}, 200, 'easeInExpo');
	});
	
	
	/******** Gestion du primetime d'une réalisation ********/
	/* Survol/désurvol des fleches */
	$('div.pageRealisation div.primetime a.flecheGauche').mouseenter(function(){
		$(this).children('img').animate({
			'margin-left': -30
		}, 100, 'easeOutBack');
	});
	$('div.pageRealisation div.primetime a.flecheGauche').mouseleave(function(){
		$(this).children('img').animate({
			'margin-left': -36
		}, 100, 'easeInBack');
	});
	
	
	$('div.pageRealisation div.primetime a.flecheDroite').mouseenter(function(){
		$(this).children('img').animate({
			'margin-left': 20
		}, 100, 'easeOutBack');
	});
	$('div.pageRealisation div.primetime a.flecheDroite').mouseleave(function(){
		$(this).children('img').animate({
			'margin-left': 26
		}, 100, 'easeInBack');
	});
	
	/* Défilement des photos du primetime d'une réalisation */
	var transitionPhotos = false;
	var nbPhotos = 0;
	$('div.pageRealisation div.primetime div.photo').each(function() { nbPhotos++; });
	var photoOuverte = 1;
	var photoAOuvrir = 1;
	$('div.pageRealisation div.primetime div#photo1').css({
		'z-index': 2,
		'top': 0
	});
	
	$('.pageRealisation div.primetime .photo').click(function(){
		
		if(transitionPhotos == false)
		{
			transitionPhotos = true;
			photoAOuvrir++;
			if(photoAOuvrir > nbPhotos) photoAOuvrir = 1;
			$('div.pageRealisation div.primetime div#photo'+photoOuverte).css('z-index', 1);
			$('div.pageRealisation div.primetime div#photo'+photoAOuvrir).css('z-index', 2);
			$('div.pageRealisation div.primetime div#photo'+photoAOuvrir).animate({
				'top': 0
			}, 500, 'easeOutExpo', function(){
				$('div.pageRealisation div.primetime div#photo'+photoOuverte).css('top', '-440px');
				photoOuverte = photoAOuvrir;
				transitionPhotos = false;
			});
		}
		return false;
	});
	
	$('div.pageRealisation div.primetime a.flecheDroite').click(function(){
		if(transitionPhotos == false)
		{
			transitionPhotos = true;
			photoAOuvrir++;
			if(photoAOuvrir > nbPhotos) photoAOuvrir = 1;
			$('div.pageRealisation div.primetime div#photo'+photoOuverte).css('z-index', 1);
			$('div.pageRealisation div.primetime div#photo'+photoAOuvrir).css('z-index', 2);
			$('div.pageRealisation div.primetime div#photo'+photoAOuvrir).animate({
				'top': 0
			}, 500, 'easeOutExpo', function(){
				$('div.pageRealisation div.primetime div#photo'+photoOuverte).css('top', '-440px');
				photoOuverte = photoAOuvrir;
				transitionPhotos = false;
			});
		}
		return false;
	});
	$('div.pageRealisation div.primetime a.flecheGauche').click(function(){
		if(transitionPhotos == false)
		{
			transitionPhotos = true;
			photoAOuvrir--;
			if(photoAOuvrir == 0) photoAOuvrir = nbPhotos;
			$('div.pageRealisation div.primetime div#photo'+photoOuverte).css('z-index', 1);
			$('div.pageRealisation div.primetime div#photo'+photoAOuvrir).css('z-index', 2);
			$('div.pageRealisation div.primetime div#photo'+photoAOuvrir).animate({
				'top': 0
			}, 500, 'easeOutExpo', function(){
				$('div.pageRealisation div.primetime div#photo'+photoOuverte).css('top', '-440px');
				photoOuverte = photoAOuvrir;
				transitionPhotos = false;
			});
		}
		return false;
	});
	
	
	/******** Gestion de la lightbox changer projet ********/
	/* ouverture/fermeture ligntbox */
	$('div.pageRealisation h1.titrePage').click(function(){
		$('div.lightboxChangerProjet').fadeIn(300, 'easeOutExpo');
		$('div.bgLightboxChangerProjet').fadeIn(300, 'easeOutExpo');
		return false;
	});
	$('div.lightboxChangerProjet, div.bgLightboxChangerProjet').click(function(){
		$('div.lightboxChangerProjet, div.bgLightboxChangerProjet').fadeOut(300, 'easeInExpo');
	});
	
	/* survol/désurvol d'un lien d'un projet */
	var reaSurvolee = '';
	var derniereReaSurvolee = '';
	var timerReaSurvolee;
	$('div.lightboxChangerProjet div.listeProjets div.projet a').mouseover(function(){
		reaSurvolee = $(this);
		timerReaSurvolee = setTimeout(afficherVignette, 300);

		$(this).parent('div.projet').children('a').animate({
			'color': '#009ddc'
		}, 300, 'easeOutQuad');
	});
	$('div.lightboxChangerProjet div.listeProjets div.projet a').mouseout(function(){
		reaSurvolee = '';
		timerReaSurvolee = clearTimeout(timerReaSurvolee);
		$(this).parent('div.projet').css('z-index', 0);
		$(this).parent('div.projet').children('div.apercu').css('z-index', 5);
		if($(this).parent('div.projet')[0].className.indexOf('actif') == -1)
		{
			$(this).parent('div.projet').children('a').animate({
				'color': '#FFF'
			}, 200, 'easeOutQuad');
		}
		$(this).parent('div.projet').children('img').fadeOut(200, 'easeInQuad');
		$(this).parent('div.projet').children('div.apercu').fadeOut(200, 'easeInQuad');
	});
	
	/* Affiche la vignette au survol d'un projet */
	function afficherVignette(){
		reaSurvolee.parent('div.projet').css('z-index', 1);
		reaSurvolee.parent('div.projet').children('img').fadeIn(200, 'easeOutQuad');
		reaSurvolee.parent('div.projet').children('div.apercu').css('z-index', 6);
		reaSurvolee.parent('div.projet').children('div.apercu').fadeIn(200, 'easeOutQuad');
	}
	
	
	
	/************************/
	/******** AGENCE ********/
	/************************/
	
	/******** Survol/desurvol des logos client ********/
	$('div.pageAgence div.clients div.listeClients div.client a').mouseover(function(){
		$(this).children('img').fadeTo(200, 0.5, 'easeOutQuad');
	});
	$('div.pageAgence div.clients div.listeClients div.client a').mouseout(function(){
		$(this).children('img').fadeTo(200, 1, 'easeInQuad');
	});
	
	
	/******** Gestion des photos du bureau ********/
	/* Survol/desurvol */
	$('div.pageAgence div.bureau div.photosBureau div.photo a').mouseover(function(){
		$(this).children('img').fadeTo(200, 0.5, 'easeOutQuad');
	});
	$('div.pageAgence div.bureau div.photosBureau div.photo a').mouseout(function(){
		$(this).children('img').fadeTo(200, 1, 'easeInQuad');
	});
	/* Paramètre de la lightbox des photos de bureau */
	$("a[rel=photoBureau]").fancybox({
		'padding' : 5,
		'margin' : 50,
		'cyclic' : true,
		
		'overlayShow' : true,
		'overlayOpacity' : 0.8,
		'overlayColor' : '#000',
		
		'titleShow' : false,
		
		'transitionIn' : 'elastic', // 'elastic', 'fade' or 'none'
		'transitionOut' : 'elastic', // 'elastic', 'fade' or 'none'
		
		'changeFade' : 100,
		
		'easingIn' : 'easeInQuart',
		'easingOut' : 'easeInQuart'
	});
	
	
	
	/************************/
	/******** BLOGUE ********/
	/************************/
	
	/******** Survol/desurvol du bouton Lire la suite ********/
	$('div.pageBlogue div.contenu a.lireLaSuite').mouseenter(function(){
		$(this).animate({
			'background-color': '#0A0A0A'
		}, 300, 'easeOutQuad');
	});
	$('div.pageBlogue div.contenu a.lireLaSuite').mouseleave(function(){
		$(this).animate({
			'background-color': '#009ddc'
		}, 300, 'easeInQuad');
	});
	
	
	/******** Gestion du retour en haut ********/
	$('div.pageBlogue div.contenu div.liens a.haut').click(function(){
		$('html').scrollTo('div.header', 600, {easing:'easeInOutExpo'});
		return false;
	});
	
	
	/******** Gestion de la box Voir nos réalisations ********/
	$('div.pageBlogue div.sidebar div.voirRealisations a').mouseenter(function(){
		$(this).children('div.ligne1').animate({
			'top': '-100'
		}, 200, 'easeInExpo');
		$(this).children('div.ligne2').delay(50).animate({
			'top': '-70'
		}, 200, 'easeInExpo');
		
		$(this).children('div.ligne1Over').delay(50).animate({
			'top': '0'
		}, 200, 'easeInExpo');
		$(this).children('div.ligne2Over').delay(100).animate({
			'top': '29'
		}, 200, 'easeInExpo');
	});
	$('div.pageBlogue div.sidebar div.voirRealisations a').mouseleave(function(){
		$(this).children('div.ligne1').delay(100).animate({
			'top': '0'
		}, 200, 'easeInExpo');
		$(this).children('div.ligne2').delay(50).animate({
			'top': '30'
		}, 200, 'easeInExpo');
		
		$(this).children('div.ligne1Over').delay(50).animate({
			'top': '100'
		}, 200, 'easeInExpo');
		$(this).children('div.ligne2Over').animate({
			'top': '130'
		}, 200, 'easeInExpo');
	});
	
	
	/******** Survol/desurvol des boutons Article Précédent/Article Suivant ********/
	$('div.pageBlogue div.contenu div.article div.navArticle a').mouseenter(function(){
		$(this).animate({
			'background-color': '#c6efff'
		}, 300, 'easeOutQuad');
	});
	$('div.pageBlogue div.contenu div.article div.navArticle a').mouseleave(function(){
		$(this).animate({
			'background-color': '#f4f4f4'
		}, 300, 'easeInQuad');
	});
	
	
	
	/******** Reposition des éléments ********/
	$(window).bind('resize', function(){
		$('div.header div.slidersTop div.contact div.map').width($('body').width()-($('body').width()-970)/2-470-10);
		$('div.header div.slidersTop div.contact div.form').css('margin-right', ($('body').width()-970)/2);
		$('div.header div.menu div.barreMenu').width(385+($('body').width()-970)/2);
		$('div.footer div.menu div.barreMenu').width(373+($('body').width()-970)/2);
		if($('body').width()<1020) $('div.footer div.bottom').width($('body').width()+10);
	});
	
	/******** affiche ligne en bas du menu actif (footer) ********/
	if($('div.pageBlogue').length > 0) {
		$('#menu-item-321').addClass('current-menu-item');
	}
	if($('div.pageRealisation').length > 0) {
		$('#menu-item-324').addClass('current-menu-item');
	}
	index = $('#menu-primary li.current-menu-item').index();
	$('#menu-primary-1 li:eq('+index+')').addClass('current-menu-item');
	
	

});



/******** Gestion des articles du blogue sur la page d'accueil ********/
var transitionArticles = false;
var nbArticles = 0;
var articleOuvert = 1;
var articleAOuvrir = 1;
var monTimerArticles;

function defilerArticles() {
	if(transitionArticles == false)
	{
		transitionArticles = true;
		
		articleAOuvrir++;
		
		if(articleAOuvrir > nbArticles) articleAOuvrir = 1;
		
		$('div.pageAccueil div.blogue div.articles div#article'+articleOuvert).css('z-index', 1);
		$('div.pageAccueil div.blogue div.articles div#article'+articleAOuvrir).css('z-index', 2);
		$('div.pageAccueil div.blogue div.articles div#article'+articleAOuvrir).animate({
			'top': 0
		}, 300, 'easeOutExpo', function(){
			$('div.pageAccueil div.blogue div.articles div#article'+articleOuvert).css('top', '-170px');
			$('div.pageAccueil div.blogue div.navigation img#nav'+articleOuvert)[0].src = stylesheet_uri+"/images/boutons/point_nav_inactif.png";
			$('div.pageAccueil div.blogue div.navigation img#nav'+articleAOuvrir)[0].src = stylesheet_uri+"/images/boutons/point_nav_actif.png";
			articleOuvert = articleAOuvrir;
			transitionArticles = false;
		});
	}


}





function getTweets(){
    var feedData = "";
    $.getJSON("http://api.twitter.com/1/users/show.json?screen_name="+userProfile+"&callback=?", function(tweetdata) {
        tweetBox_json.profile = new Object;
        tweetBox_json.profile.screen_name = tweetdata.screen_name;
        tweetBox_json.profile.avatar = tweetdata.profile_image_url;
        tweetBox_json.profile.name = tweetdata.name;
        tweetBox_json.profile.followers_count = tweetdata.followers_count;
        tweetBox_json.profile.statuses_count = tweetdata.statuses_count;
        tweetBox_json.profile.friends_count = tweetdata.friends_count;
    })
    .complete(function(){
        $.getJSON("http://api.twitter.com/1/statuses/user_timeline.json?screen_name="+userProfile+"&count=100&callback=?", function(tweetdata) {
            // For each item returned in tweetdata
            $.each(tweetdata, function(i, tweet) {
                tweetBox_json.tweets[i] = new Object;
                if ( tweet.text.search('http') != -1)
                {
                        var url = 'http'+ tweet.text.split('http')[1].split(' ')[0] ;
                        var nextText = tweet.text.split('http')[1].split(' ')[1] ;
                        tweet.text = tweet.text.split('http')[0] + '<a href="' + url + '">' + url + '</a> ' ;
                        if (nextText)
                            tweet.text += nextText ;
                }
                tweetBox_json.tweets[i].text = tweet.text;//
                tweetBox_json.tweets[i].created_at = dateFormat(new Date(tweet.created_at).toString(), "dd mmm à HH:MM") ;
                tweetBox_json.tweets[i].location = tweet.user.location;
                tweetBox_json.tweets[i].image = tweet.user.profile_image_url;
                tweetBox_json.tweets[i].retweeted = tweet.retweeted;
                tweetBox_json.tweets[i].retweet_count = tweet.retweet_count;
            });
        })
    });
}

function displayLastTweet()
{
    if (!tweetBox_json.tweets.length)
    {
            setTimeout(displayLastTweet, 1000) ;
            return false ;
    }
    $('.bulle .tweet').html('<table><tr><td valign="top"><img src="'+tweetBox_json.tweets[0].image+'"/></td><td style="padding-left:20px;">'+
        tweetBox_json.tweets[0].text+'<div class="tweetDate">'+
        tweetBox_json.tweets[0].created_at+' depuis <b>'+tweetBox_json.tweets[0].location+
        '</b></div></td></tr></table>') ;
    return true;
}

/**
 * Date.parse with progressive enhancement for ISO-8601
 * © 2010 Colin Snover <http://zetafleet.com>
 * Released under MIT license.
 */
(function () {
    'use strict';
    var origParse = Date.parse;
    Date.parse = function (date) {
        var timestamp = origParse(date), minutesOffset = 0, struct;
        if (isNaN(timestamp) && (struct = /(\d{4})-?(\d{2})-?(\d{2})(?:[T ](\d{2}):?(\d{2}):?(\d{2})?(?:\.(\d{3,}))?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?))/.exec(date))) {
            if (struct[8] !== 'Z') {
                minutesOffset = +struct[10] * 60 + (+struct[11]);
                
                if (struct[9] === '+') {
                    minutesOffset = 0 - minutesOffset;
                }
            }
            
            timestamp = Date.UTC(+struct[1], +struct[2] - 1, +struct[3], +struct[4], +struct[5] + minutesOffset, +struct[6]);
        }
        
        return timestamp;
    };
}());
