var refAffiche = -1;
function afficheRef(i)
{
	var chdata = "idRef="+refAffiche;
	if(i != -1)	chdata += "&idSol="+i;
	$.ajax({
		url: 'http://www.avanti-technologies.fr/affref.php',
		type: 'get',
		data: chdata,
		cache: false,
		dataType: 'html',
		success: function (data) {
			$('#img').html(data);
			$('#img img:last-child').load(function(e)	{
				$('#img img').show();	
			});
			refAffiche = $('#img img').attr('class');
		},
		error: function (xhr) {
			$('#img').html(xhr.status + ': ' + xhr.statusText);
		}
	});
	setTimeout('afficheRef('+i+');',3000);
}
var temAffiche = 0;
function afficheTem(a)
{
	if(a == 1)
	{
		temAffiche++;
		if($('#tem'+temAffiche).size() == 0)
		{
			temAffiche--;
			return false;
		}
	}
	if(a == 2)
	{
		temAffiche--;
		if($('#tem'+temAffiche).size() == 0)
		{
			temAffiche++;
			return false;
		}
	}
	var temAffiche2 = temAffiche+1;
	if($('#tem'+temAffiche2).size() == 0)	
		$('#temoignage .barre .nav span.right').css('background','url(images/nav.png) no-repeat -20px -36px').css('cursor','default');
	else
		$('#temoignage .barre .nav span.right').css('background','url(images/nav.png) no-repeat -20px 0').css('cursor','pointer');
	var temAffiche2 = temAffiche-1;
	if($('#tem'+temAffiche2).size() == 0)	
		$('#temoignage .barre .nav span.left').css('background','url(images/nav.png) no-repeat 0 -36px').css('cursor','default');
	else
		$('#temoignage .barre .nav span.left').css('background','url(images/nav.png) no-repeat 0 0').css('cursor','pointer');
	$('.divTem').hide();
	$('#tem'+temAffiche).effect( 'slide', { direction: "right" }, 250, '' );
}
var actuAffiche = 0;
function afficheActu(a)
{
	if(a == 1)
	{
		actuAffiche++;
		if($('#actu'+actuAffiche).size() == 0)
		{
			actuAffiche--;
			return false;
		}
	}
	if(a == 2)
	{
		actuAffiche--;
		if($('#actu'+actuAffiche).size() == 0)
		{
			actuAffiche++;
			return false;
		}
	}
	var actuAffiche2 = actuAffiche+1;
	if($('#actu'+actuAffiche2).size() == 0)	
		$('#news .barre .nav span.right').css('background','url(images/nav.png) no-repeat -20px -36px').css('cursor','default');
	else
		$('#news .barre .nav span.right').css('background','url(images/nav.png) no-repeat -20px 0').css('cursor','pointer');
	var actuAffiche2 = actuAffiche-1;
	if($('#actu'+actuAffiche2).size() == 0)	
		$('#news .barre .nav span.left').css('background','url(images/nav.png) no-repeat 0 -36px').css('cursor','default');
	else
		$('#news .barre .nav span.left').css('background','url(images/nav.png) no-repeat 0 0').css('cursor','pointer');
	$('.divActu').hide();
	$('#actu'+actuAffiche).effect( 'slide', { direction: "right" }, 250, '' );
}
var teaserAffiche = 1;
var T_GLOBAL = false;
function afficherTeaserAccueil()
{
	$('#accueilsociete div').hide();
	teaserAffiche++;
	if($('#accueilsociete div').size() < teaserAffiche)
		teaserAffiche = 1;	
	$('#accueilsociete #slide'+teaserAffiche).fadeIn(500);
	clearInterval(T_GLOBAL);
	T_GLOBAL = setTimeout('afficherTeaserAccueil();',7000);
}
var animationEnCours = false;
var tab=new Array;
var current;
var current2;
tab["societeteaserimage"] = 'societe.png';
tab["solutionteaserimage"] = 'solutions.png';tab["solutionsubmenu"] = 'solution1|solution2';
tab["mediateaserimage"] = 'media.png';
tab["referencesteaserimage"] = 'references.png';
tab["partenairesteaserimage"] = 'partenaire.png';
tab["mentionslegalesteaserimage"] = 'mentionslegales.png';
tab["contactHteaserimage"] = 'contact.png';
tab["supportHteaserimage"] = 'support.png';
tab["recrutementHteaserimage"] = 'recrutement.png';
tab["Sitesteaserimage"] = 'site.png';
tab["Agencesteaserimage"] = 'agences.png';
tab["Publicteaserimage"] = 'public.png';
tab["Hotelsteaserimage"] = 'hotels.png';
tab["Traiteursteaserimage"] = 'traiteurs.png';
tab["GrandsComptesteaserimage"] = 'gc.png';
tab["Organisateurteaserimage"] = 'orga.png';

$(document).ready(function() {
	$("#menu ul").lavaLamp({ fx: 'backout', speed: 700 });
	$('.submenu').hide();
	afficheTem(0);
	afficheActu(0);
	current = $('.current');
	current2 = $('.current');
	if((current2.attr('id') == 'accueil')&&($('#mentionslegales').attr('class') =='current'))
	{
		current = $('#mentionslegales');
		current2 = $('#mentionslegales');
	}
	if(current.attr('id') == 'accueil')
	{
		$('#teaser').css('background','none');
		$('#accueilsociete,#accueilsociete2').show();
		teaserAffiche = 0;	
		clearInterval(T_GLOBAL);
		afficherTeaserAccueil();
	}
	else
	{
		$('#accueilsociete,#accueilsociete2').hide();
		if(tab[current.attr('id')+'submenu'] || 0)
		{
			var submenus = tab[current.attr('id')+'submenu'].split('|');
			for(var i= 0; i < submenus.length; i++)	{
				 $('#'+submenus[i]).show();
			}
		}
		$('#teaser').css('background','url(http://www.avanti-technologies.fr/images/'+tab[current.attr('id')+'teaserimage']+') no-repeat 0 0');
	}
	$('.accordeon').hide();
	$('#solution2').tagSphere({ 
		height: 120,
		width: 255,        
		slower: 1,
		speed: 0.25,
        radius: 50,
        timer: 1
	});
});
jQuery(function ($) {
	$('.niv1').hover(function(e)	{
		if(($(this).attr('id') == 'mentionslegales')||($(this).attr('id') == 'contactH')||($(this).attr('id') == 'supportH')||($(this).attr('id') == 'recrutementH'))
			return false;
		if(($(this).attr('id') == current2.attr('id'))&&(current2.attr('id') == 'accueil'))	return false;
		current2.css('background','none');
		$('#'+current2.attr('id')+' .left2').css('background','none');
		$('#lienH #contactH').css('background','url(http://www.avanti-technologies.fr/images/casque.png) no-repeat');
		$('#lienH #supportH').css('background','url(http://www.avanti-technologies.fr/images/param.png) no-repeat');
		$('#lienH #recrutementH').css('background','url(http://www.avanti-technologies.fr/images/msn.png) no-repeat');
		$('#menu ul li.back').css('background','url(http://www.avanti-technologies.fr/images/menu.png) no-repeat bottom left');
		$('#menu ul li.back .left').css('background','url(http://www.avanti-technologies.fr/images/lava.png) no-repeat bottom right');
		current2 = $(this); 
		
		$('.submenu').hide();
		if(current2.attr('id') == 'accueil')
		{
			$('#teaser').css('background','none');
			$('#accueilsociete,#accueilsociete2').show();
			clearInterval(T_GLOBAL);
			teaserAffiche = 0;
			afficherTeaserAccueil();
		}
		else
		{
			clearInterval(T_GLOBAL);
			teaserAffiche = 0;
			$('#accueilsociete,#accueilsociete div,#accueilsociete2').hide();
			if((current2.attr('id') == 'Sites')||(current2.attr('id') == 'Agences')||(current2.attr('id') == 'Public')||(current2.attr('id') == 'Hotels')||(current2.attr('id') == 'Traiteurs')||(current2.attr('id') == 'GrandsComptes')||(current2.attr('id') == 'Organisateur'))
			{
				var submenus = tab['solutionsubmenu'].split('|');
				for(var i= 0; i < submenus.length; i++)	{
						$('#'+submenus[i]).show();
				}
				$('#teaser').css('background','url(http://www.avanti-technologies.fr/images/'+tab['solutionteaserimage']+') no-repeat 0 0');
			}
			else
			{
				if(tab[current2.attr('id')+'submenu'] || 0)
				{
					var submenus = tab[current2.attr('id')+'submenu'].split('|');
					for(var i= 0; i < submenus.length; i++)	{
						 $('#'+submenus[i]).show();
					}
				}
				$('#teaser').css('background','url(http://www.avanti-technologies.fr/images/'+tab[current2.attr('id')+'teaserimage']+') no-repeat 0 0');
			}
		}
	},function(e)	{
	});
	$('#teaser').hover(function(e)	{
		if((current2.attr('id') == 'mentionslegales')||(current2.attr('id') == 'contactH')||(current2.attr('id') == 'supportH')||(current2.attr('id') == 'recrutementH'))
			return false;
		else
		{
			$('#menu ul li.back').css('background','none');
			$('#menu ul li.back .left').css('background','none');
			current2.css('background','url(http://www.avanti-technologies.fr/images/menu.png) no-repeat top left');
			$('#'+current2.attr('id')+' .left2').css('background','url(http://www.avanti-technologies.fr/images/lava.png) no-repeat bottom right');
		}
		
	},function(e)	{
	});
	$('#menuBlock').hover(function(e)	{
	},function(e)	{
		if((current.attr('id') == current2.attr('id'))&&(current.attr('id') == 'accueil'))	return false;
		current2.css('background','none');
		$('#'+current2.attr('id')+' .left2').css('background','none');
		current2 = current;
		$('#lienH #contactH').css('background','url(http://www.avanti-technologies.fr/images/casque.png) no-repeat');
		$('#lienH #supportH').css('background','url(http://www.avanti-technologies.fr/images/param.png) no-repeat');
		$('#lienH #recrutementH').css('background','url(http://www.avanti-technologies.fr/images/msn.png) no-repeat');
		$('#menu ul li.back').css('background','url(http://www.avanti-technologies.fr/images/menu.png) no-repeat bottom left');
		$('#menu ul li.back .left').css('background','url(http://www.avanti-technologies.fr/images/lava.png) no-repeat bottom right');
		if(current.attr('id') == 'accueil')
		{
			$('#accueilsociete,#accueilsociete2').show();
			$('#teaser').css('background','none');
			clearInterval(T_GLOBAL);
			afficherTeaserAccueil();
		}
		else
		{
			teaserAffiche = 0;
			clearInterval(T_GLOBAL);
			$('#accueilsociete,#accueilsociete2').hide();
			$('#teaser').css('background','url(http://www.avanti-technologies.fr/images/'+tab[current.attr('id')+'teaserimage']+') no-repeat 0 0');
		}
		$('.submenu').hide();
		if(tab[current.attr('id')+'submenu'] || 0)
		{
			var submenus = tab[$('.current').attr('id')+'submenu'].split('|');
			for(var i= 0; i < submenus.length; i++)	{
				 $('#'+submenus[i]).show();
			}
		}
	});
	$('#accueilsociete2').hover(function(e)	{
		clearInterval(T_GLOBAL);
		$('#accueilsociete div').hide();
		$(this).animate({width:"670px",marginLeft:"290px"}, { queue: false	}, 400);
		$('#accueilsolutions,#accueilevent').animate({width:"670px"}, { queue: false	}, 400);
		$('#accueilsociete').animate({width:"270px"}, { queue: false	}, 400);
	},function(e)	{
		$(this).animate({width:"270px",marginLeft:"690px"}, 400);
		$('#accueilsolutions,#accueilevent').animate({width:"270px",height:"130px"}, { queue: false	}, 400);
		$('#accueilsociete').animate({width:"670px"}, { queue: false	}, 400, function() {	$('#accueilsociete div').show();	});
		clearInterval(T_GLOBAL);
		teaserAffiche = 0;
		T_GLOBAL = setTimeout('afficherTeaserAccueil();',500);
	});
	$('#accueilsolutions').hover(function(e)	{
		clearInterval(T_GLOBAL);
		$(this).animate({height:"160px"}, { queue: false	}, 400);
		$('#accueilevent').animate({height:"100px"}, { queue: false	}, 400);
	});
	$('#accueilevent').hover(function(e)	{
		clearInterval(T_GLOBAL);
		$(this).animate({height:"160px"}, { queue: false	}, 400);
		$('#accueilsolutions').animate({height:"100px"}, { queue: false	}, 400);
	});
	$('#solution2 li,.menuGauche li').hover(function(e)	{
		$(this).css('color','#f7941d');
		$('ul',this).show();
	},function(e)	{
		$(this).css('color','#000');
		$('ul',this).hide();
	});
	$('.devis a,.rappeler a,.lienNews').click(function(e) {
		e.preventDefault();
		$(this).parent().next('.conteneur').show().next('.conteneur2').show();
		$(this).parent().next('.conteneur').next('.conteneur2').css('margin-top',-(($(this).parent().next('.conteneur').next('.conteneur2').height())/2));
		$(this).parent().next('.conteneur').next('.conteneur2').css('margin-left',-(($(this).parent().next('.conteneur').next('.conteneur2').width())/2));
	});
	$('.btnAnnuler').click(function(e) {
		e.preventDefault();
		$(this).parent().parent().hide().prev('.conteneur').hide();
	});
	$('#Envoyer').click(function(e) {
		e.preventDefault();
		msg($('#nomSoluce').val()+' - Demande de devis',1);
	});
	$('#Envoyer2').click(function(e) {
		e.preventDefault();
		msg($('#nomSoluce').val()+' - Etre rappele',2);
	});
	$('#Envoyer3').click(function(e) {
		e.preventDefault();
		msg($(this).next('#nomSoluce').val()+' - Prendre rendez-vous',3);
	});
	/**Accordéon avantages et fonctionnalités des solutions et recrutement**/
	$('.ferme,.active').click(function() { // si on clique sur un titre
		if($(this).attr('class') == 'ferme')
		{
			$('.active').removeClass('active').addClass('ferme');
			$(this).removeClass('ferme').addClass('active');
			$(this).next('.accordeon').slideDown() // on deroule le div caché qui suit directement le titre
			$('.ferme').next('.accordeon').slideUp(); // et on cache les div similaires qui etait visible
		}
		else
		{
			$(this).next('.accordeon').slideUp()
			setTimeout("$('.active').removeClass('active').addClass('ferme');",400);
		}
	});
	/**Recherche recrutement**/
	$('.service').click(function() {
		$.ajax({
			url: 'offreemploi.php',
			type: 'get',
			data: "service="+$(this).val(),
			cache: false,
			dataType: 'html',
			success: function (data) {
				$('.accordeonRecrutement').html(data);
				$('.accordeon').hide();
				$('.ferme,.active').click(function() { // si on clique sur un titre
					if($(this).attr('class') == 'ferme')
					{
						$('.active').removeClass('active').addClass('ferme');
						$(this).removeClass('ferme').addClass('active');
						$(this).next('.accordeon').slideDown() // on deroule le div caché qui suit directement le titre
						$('.ferme').next('.accordeon').slideUp(); // et on cache les div similaires qui etait visible
					}
					else
					{
						$(this).next('.accordeon').slideUp()
						setTimeout("$('.active').removeClass('active').addClass('ferme');",400);
					}
				});
			},
			error: function (xhr) {
				$('.accordeonRecrutement').html(xhr.status + ': ' + xhr.statusText);
			}
		});
	});
	$('#formCandSpon').submit(function(event) {
		var msg = '';
		if($('#candSpon #poste').val() == "")
		{
			if(msg == '')	msg = 'Champs obligatoires: Poste';
			else	msg += ', Poste';
			$('#candSpon #poste').css('background','#f7941d');
		}
		if($('#candSpon #nom').val() == "")
		{
			if(msg == '')	msg = 'Champs obligatoires: Nom';
			else	msg += ', Nom';
			$('#candSpon #nom').css('background','#f7941d');
		}
		if($('#candSpon #prenom').val() == "")
		{
			if(msg == '')	msg = 'Champs obligatoires: Prénom';
			else	msg += ', Prénom';
			$('#candSpon #prenom').css('background','#f7941d');
		}
		if($('#candSpon #tel').val() == "")
		{
			if(msg == '')	msg = 'Champs obligatoires: Téléphone';
			else	msg += ', Téléphone';
			$('#candSpon #tel').css('background','#f7941d');
		}
		if($('#candSpon #cv').val() == "")
		{
			if(msg == '')	msg = 'Champs obligatoires: CV';
			else	msg += ', CV';
			$('#candSpon #cv').css('background','#f7941d');
		}
		if($('#candSpon #email').val()=='')
		{
			if(msg == '')	msg = 'Champs obligatoires: Email';
			else	msg += ', Email';
			$('#candSpon #email').css('background','#f7941d');
		}
		else
		{
			if(!valideMail($('#candSpon #email').val()))
			{
				if(msg == '')	msg = 'Email invalide';
				else	msg += '<br /><br />Email invalide';
				$('#candSpon #email').css('background','#f7941d');
			}
			else	$('#candSpon #email').css('background','');
		}
		if(msg != '')
		{
			$('#contenuCandSpon #msg').html(msg).css('color','#f7941d').css('margin','10px auto');
			return false;
		}
		else
		{
			return true;
		}
		return false;
	});
});
var chmsg = '';
var message = '';
function msg(solution,type)	{
	var ch = '';
	if(type == 1)	ch = 'ddedevis';
	if(type == 2)	ch = 'etrerappeler';
	if(type == 3)	ch = 'dderdvsalon';
	chmsg = $('#'+ch+' .message');
	chmsg.css('width',$('#'+ch).width());
	chmsg.html('');
	message = '';
	if($('#'+ch+' #nom'+type).val()=='')
	{
		if(message == '')	message = 'Champs obligatoires: Nom';
		else	message += ', Nom';
		$('#'+ch+' #nom'+type).css('background','#f7941d');
	}
	else	$('#'+ch+' #nom'+type).css('background','');
	if($('#'+ch+' #org'+type).val()=='')
	{
		if(message == '')	message = 'Champs obligatoires: Organisation';
		else	message += ', Organisation';
		$('#'+ch+' #org'+type).css('background','#f7941d');
	}
	else	$('#'+ch+' #org'+type).css('background','');
	if($('#'+ch+' #tel'+type).val()=='')
	{
		if(message == '')	message = 'Champs obligatoires: Téléphone';
		else	message += ', Téléphone';
		$('#'+ch+' #tel'+type).css('background','#f7941d');
	}
	else	$('#'+ch+' #tel'+type).css('background','');
	if((type == 1)||(type == 3))	{
		if($('#'+ch+' #prenom'+type).val()=='')
		{
			if(message == '')	message = 'Champs obligatoires: Prenom';
			else	message += ', Prenom';
			$('#'+ch+' #prenom'+type).css('background','#f7941d');
		}
		else	$('#'+ch+' #prenom'+type).css('background','');
		if($('#'+ch+' #email'+type).val()=='')
		{
			if(message == '')	message = 'Champs obligatoires: Email';
			else	message += ', Email';
			$('#'+ch+' #email'+type).css('background','#f7941d');
		}
		else
		{
			if(!valideMail($('#'+ch+' #email'+type).val()))
			{
				if(message == '')	message = 'Email invalide';
				else	message += '<br /><br />Email invalide';
				$('#'+ch+' #email'+type).css('background','#f7941d');
			}
			else	$('#'+ch+' #email'+type).css('background','');
		}
	}
	if(message != '')	chmsg.html(message);
	else
	{
		if((type == 1)||(type == 3))	chdata = 'nom='+$('#'+ch+' #nom'+type).val()
												+'&prenom='+$('#'+ch+' #prenom'+type).val()
												+'&societe='+$('#'+ch+' #org'+type).val()
												+'&fonction='+$('#'+ch+' #fonction'+type).val()
												+'&tel='+$('#'+ch+' #tel'+type).val()
												+'&email='+$('#'+ch+' #email'+type).val()
												+'&question='+$('#'+ch+' #quest'+type).val()
												+'&sujet='+solution
												+'&action=send';
		if(type == 2)	chdata = 'nom='+$('#'+ch+' #nom'+type).val()
								+'&societe='+$('#'+ch+' #org'+type).val()
								+'&tel='+$('#'+ch+' #tel'+type).val()
								+'&sujet='+solution
								+'&action=send';
		try{
			$.ajax({
				url: 'http://www.avanti-technologies.fr/mail.php',
				data: chdata,
				type: 'post',
				cache: false,
				dataType: 'html',
				success: function (data) {
					chmsg.html(data);
					$('.conteneur2').delay(2000).slideUp('slow');
					$('.conteneur').delay(2500).fadeOut(400);
					$('.conteneur2 input,.conteneur2 textarea').val('');
				},
				error: function (xhr) {
					chmsg.html(xhr.status + ': ' + xhr.statusText);
				}
			});
		}
		catch(e)	{	alert(e);	}
	}
}
function valideMail(email) 	{
	var at = email.lastIndexOf("@");

	// Make sure the at (@) sybmol exists and  
	// it is not the first or last character
	if (at < 1 || (at + 1) === email.length)
		return false;

	// Make sure there aren't multiple periods together
	if (/(\.{2,})/.test(email))
		return false;

	// Break up the local and domain portions
	var local = email.substring(0, at);
	var domain = email.substring(at + 1);

	// Check lengths
	if (local.length < 1 || local.length > 64 || domain.length < 4 || domain.length > 255)
		return false;

	// Make sure local and domain don't start with or end with a period
	if (/(^\.|\.$)/.test(local) || /(^\.|\.$)/.test(domain))
		return false;

	// Check for quoted-string addresses
	// Since almost anything is allowed in a quoted-string address,
	// we're just going to let them go through
	if (!/^"(.+)"$/.test(local)) {
		// It's a dot-string address...check for valid characters
		if (!/^[-a-zA-Z0-9!#$%*\/?|^{}`~&'+=_\.]*$/.test(local))
			return false;
	}

	// Make sure domain contains only valid characters and at least one period
	if (!/^[-a-zA-Z0-9\.]*$/.test(domain) || domain.indexOf(".") === -1)
		return false;	

	return true;
}

/****Carousel référence*****/
(function($){function Reflection(img,reflHeight,opacity){var reflection,cntx,imageWidth=img.width,imageHeight=img.width,gradient,parent;parent=$(img.parentNode);this.element=reflection=parent.append("<canvas class='reflection' style='position:absolute'/>").find(':last')[0];if(!reflection.getContext&&$.browser.msie){this.element=reflection=parent.append("<img class='reflection' style='position:absolute'/>").find(':last')[0];reflection.src=img.src;reflection.style.filter="flipv progid:DXImageTransform.Microsoft.Alpha(opacity="+(opacity*100)+", style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy="+(reflHeight/imageHeight*100)+")"}else{cntx=reflection.getContext("2d");try{$(reflection).attr({width:imageWidth,height:reflHeight});cntx.save();cntx.translate(0,imageHeight-1);cntx.scale(1,-1);cntx.drawImage(img,0,0,imageWidth,imageHeight);cntx.restore();cntx.globalCompositeOperation="destination-out";gradient=cntx.createLinearGradient(0,0,0,reflHeight);gradient.addColorStop(0,"rgba(255, 255, 255, "+(1-opacity)+")");gradient.addColorStop(1,"rgba(255, 255, 255, 1.0)");cntx.fillStyle=gradient;cntx.fillRect(0,0,imageWidth,reflHeight)}catch(e){return}}$(reflection).attr({'alt':$(img).attr('alt'),title:$(img).attr('title')})}var Item=function(imgIn,options){this.orgWidth=imgIn.width;this.orgHeight=imgIn.height;this.image=imgIn;this.reflection=null;this.alt=imgIn.alt;this.title=imgIn.title;this.imageOK=false;this.options=options;this.imageOK=true;if(this.options.reflHeight>0){this.reflection=new Reflection(this.image,this.options.reflHeight,this.options.reflOpacity)}$(this.image).css('position','absolute')};var Controller=function(container,images,options){var items=[],funcSin=Math.sin,funcCos=Math.cos,ctx=this;this.controlTimer=0;this.stopped=false;this.container=container;this.xRadius=options.xRadius;this.yRadius=options.yRadius;this.showFrontTextTimer=0;this.autoRotateTimer=0;if(options.xRadius===0){this.xRadius=($(container).width()/2.3)}if(options.yRadius===0){this.yRadius=($(container).height()/6)}this.xCentre=options.xPos;this.yCentre=options.yPos;this.frontIndex=0;this.rotation=this.destRotation=Math.PI/2;this.timeDelay=1000/options.FPS;if(options.altBox!==null){$(options.altBox).css('display','block');$(options.titleBox).css('display','block')}$(container).css({position:'relative',overflow:'hidden'});$(options.buttonLeft).css('display','inline');$(options.buttonRight).css('display','inline');$(options.buttonLeft).bind('mouseup',this,function(event){event.data.rotate(-1);return false});$(options.buttonRight).bind('mouseup',this,function(event){event.data.rotate(1);return false});if(options.mouseWheel){$(container).bind('mousewheel',this,function(event,delta){event.data.rotate(delta);return false})}$(container).bind('mouseover click',this,function(event){clearInterval(event.data.autoRotateTimer);var text=$(event.target).attr('alt');if(text!==undefined&&text!==null){clearTimeout(event.data.showFrontTextTimer);$(options.altBox).html(($(event.target).attr('alt')));$(options.titleBox).html(($(event.target).attr('title')));if(options.bringToFront&&event.type=='click'){var idx=$(event.target).data('itemIndex');var frontIndex=event.data.frontIndex;var diff=(idx-frontIndex)%images.length;if(Math.abs(diff)>images.length/2){diff+=(diff>0?-images.length:images.length)}event.data.rotate(-diff)}}});$(container).bind('mouseout',this,function(event){var context=event.data;clearTimeout(context.showFrontTextTimer);context.showFrontTextTimer=setTimeout(function(){context.showFrontText()},1000);context.autoRotate()});$(container).bind('mousedown',this,function(event){event.data.container.focus();return false});container.onselectstart=function(){return false};this.innerWrapper=$(container).wrapInner('<div style="position:absolute;width:100%;height:100%;"/>').children()[0];this.showFrontText=function(){if(items[this.frontIndex]===undefined){return}$(options.titleBox).html($(items[this.frontIndex].image).attr('title'));$(options.altBox).html($(items[this.frontIndex].image).attr('alt'))};this.go=function(){if(this.controlTimer!==0){return}var context=this;this.controlTimer=setTimeout(function(){context.updateAll()},this.timeDelay)};this.stop=function(){clearTimeout(this.controlTimer);this.controlTimer=0};this.rotate=function(direction){this.frontIndex-=direction;this.frontIndex%=items.length;this.destRotation+=(Math.PI/items.length)*(2*direction);this.showFrontText();this.go()};this.autoRotate=function(){if(options.autoRotate!=='no'){var dir=(options.autoRotate==='right')?1:-1;this.autoRotateTimer=setInterval(function(){ctx.rotate(dir)},options.autoRotateDelay)}};this.updateAll=function(){var minScale=options.minScale;var smallRange=(1-minScale)*0.5;var w,h,x,y,scale,item,sinVal;var change=(this.destRotation-this.rotation);var absChange=Math.abs(change);this.rotation+=change*options.speed;if(absChange<0.001){this.rotation=this.destRotation}var itemsLen=items.length;var spacing=(Math.PI/itemsLen)*2;var radians=this.rotation;var isMSIE=$.browser.msie;this.innerWrapper.style.display='none';var style;var px='px',reflHeight;var context=this;for(var i=0;i<itemsLen;i++){item=items[i];sinVal=funcSin(radians);scale=((sinVal+1)*smallRange)+minScale;x=this.xCentre+(((funcCos(radians)*this.xRadius)-(item.orgWidth*0.5))*scale);y=this.yCentre+(((sinVal*this.yRadius))*scale);if(item.imageOK){var img=item.image;w=img.width=item.orgWidth*scale;h=img.height=item.orgHeight*scale;img.style.left=x+px;img.style.top=y+px;img.style.zIndex=""+(scale*100)>>0;if(item.reflection!==null){reflHeight=options.reflHeight*scale;style=item.reflection.element.style;style.left=x+px;style.top=y+h+options.reflGap*scale+px;style.width=w+px;if(isMSIE){style.filter.finishy=(reflHeight/h*100)}else{style.height=reflHeight+px}}}radians+=spacing}this.innerWrapper.style.display='block';if(absChange>=0.001){this.controlTimer=setTimeout(function(){context.updateAll()},this.timeDelay)}else{this.stop()}};this.checkImagesLoaded=function(){var i;for(i=0;i<images.length;i++){if((images[i].width===undefined)||((images[i].complete!==undefined)&&(!images[i].complete))){return}}for(i=0;i<images.length;i++){items.push(new Item(images[i],options));$(images[i]).data('itemIndex',i)}clearInterval(this.tt);this.showFrontText();this.autoRotate();this.updateAll()};this.tt=setInterval(function(){ctx.checkImagesLoaded()},50)};$.fn.Carousel=function(options){this.each(function(){options=$.extend({},{reflHeight:75,reflOpacity:0.5,reflGap:0,minScale:0.5,xPos:450,yPos:50,xRadius:0,yRadius:0,altBox:null,titleBox:null,FPS:30,autoRotate:'left',autoRotateDelay:1750,speed:0.1,mouseWheel:true,bringToFront:true},options);$(this).data('carousel',new Controller(this,$('.carousel',$(this)),options))});return this}})(jQuery);

/****Media - Photos*****/
var imgAffiche = 0;
var animationPhoto = false;
function affichePhoto()
{
	if($('#galerie #photo'+imgAffiche).size() == 0)
	{
		if(imgAffiche<0)
			imgAffiche = $('#galerie img').size()-1;
		else
			imgAffiche = 0;
	}
	$('#galerie #photo'+imgAffiche).fadeIn(500);
}
jQuery(function ($) {
	$('#photoprecedente').click(function(e)	{
		e.preventDefault();
		while(animationPhoto)	{}
		animationPhoto = true;
		$('#galerie #photo'+imgAffiche).fadeOut(0);
		imgAffiche--;
		affichePhoto();
		animationPhoto = false;
	});
	$('#photosuivante').click(function(e)	{
		e.preventDefault();
		while(animationPhoto)	{}
		animationPhoto = true;
		$('#galerie #photo'+imgAffiche).fadeOut(0);
		imgAffiche++;
		affichePhoto();
		animationPhoto = false;
	});
	/****Media Presse****/
	$('#presse .plus').click(function() { // si on clique sur un titre
		if($(this).html() == 'En savoir plus...')
		{
			$(this).prev('.ensavoirplus').show();
			$(this).html('Moins de détails');
		}
		else
		{
			$(this).prev('.ensavoirplus').hide();
			$(this).html('En savoir plus...');
		}
	});
	/**Actualites**/
	$('#news span.right').click(function() {
		afficheActu(1);
	});
	$('#news span.left').click(function() {
		afficheActu(2);
	});
	/**Temoignages**/
	$('#temoignage span.right').click(function() {
		afficheTem(1);
	});
	$('#temoignage span.left').click(function() {
		afficheTem(2);
	});
});
