	jQuery(function() {
		var loaderContact = jQuery('img#chargementMail').hide();
		jQuery().ajaxStart(function() {
			loaderContact.show();
		}).ajaxStop(function() {
			loaderContact.hide();
			$('#cprenom').val("");
			$('#cnom').val("");
			$('#cemail').val("");
			$('#cmessage').val("");
			$('#ccopie').attr('checked', false);
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		var v = jQuery("#contactForm").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#result"
				});
			}
		});
		
		var v2 = jQuery("#commentform").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#result"
				});
			}
		});
	});	
	
	$(document).ready(function(){
	
		$('#imgHeader').cycle({
			fx: 'fade',
			timeout: 7000,
			speed: 800,
			slideExpr: 'img'
		});
		
		$('textarea').elastic();
		
		if ($.browser.msie && $.browser.version == '6.0') {
			$('.btonPlayVideo').css("display","none");
			$('.btonPlayVideoSlider').css("display","none");
		}
		
		$('.bulle').css('word-wrap','break-word');
		$('.bulleEnCours').css('word-wrap','break-word');
		$('.bulleLast').css('word-wrap','break-word');
		
		$('.planSiteContent ul > li:last-child').css('border','none');
		$('.planSiteContent ul > li:last-child').css('padding-bottom','0');
		$('#boxMediaDocument > p:last-child').css('border','none');
		$('#boxMediaDocument > p:last-child').css('padding-bottom','0');

		$("div#headerOpacite").css("opacity", "0.7");
		// $("div#loaderTraduction").css("opacity", "0.7");
		$("span.dureeVideo").css("opacity", "0.7");
		$("span.dureeVideoSlider").css("opacity", "0.7");
		$("div#boxFeatured").corner();
		$("div.box").corner("bottom");
		$("div.boxListe").corner("bottom");
		$("div.boxPage").corner("bottom");
		$("div.boxComment").corner("bottom");
		// $(".boxPage h3").corner();
		$("div.boxSidebar").corner("bottom");
		$("div.sidebarVideoItem").corner("bottom");
		$("div.photoSingle").corner();

		$("div.panel-wrapper").hover(function(){
		   $(this).find("span.iconeZoom").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoom").css("background-position","top left");
		 });
		 
		$("div.sidebarVideoItem").hover(function(){
		   $(this).find("span.iconeZoomSidebar").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoomSidebar").css("background-position","top left");
		 });
		 
		$("div.photoSingle").hover(function(){
		   $(this).find("span.iconeZoom").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoom").css("background-position","top left");
		 });
		 
		$("div.trombiItem").hover(function(){
		   $(this).find("span.iconeZoom").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoom").css("background-position","top left");
		 });
		 
		$("div.galeriePhotoItem").hover(function(){
		   $(this).find("span.iconeZoom").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoom").css("background-position","top left");
		 });
		 
		$("div.galerieVideoItem").hover(function(){
		   $(this).find("span.iconeZoom").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoom").css("background-position","top left");
		 });
		 
		 
		$("a.sliderVideoItem").hover(function(){
		   $(this).find("span.iconeZoom").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoom").css("background-position","top left");
		 });
		 
		$("a.galerieVideoItem").hover(function(){
		   $(this).find("span.iconeZoom").css("background-position","bottom left");
		 },function(){
		   $(this).find("span.iconeZoom").css("background-position","top left");
		 });
		 
		$("div#dropdownMessage").hover(function(){
		   $(this).addClass("dropDownMessageHover");
		 },function(){
		   $(this).removeClass("dropDownMessageHover");
		 });
		 		
		miseEnPause = false; // Variable utilisˇe dans les callbacks de la prettyPhoto
	
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.7, /* Value betwee 0 and 1 */
			showTitle: false, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: ' sur ', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			modal: false, /* If set to true, only the close button will close the window */
			changepicturecallback: function(){
				if($("#player_play").css("display") == "none")
				{
					miseEnPause = true;
					$("#jquery_jplayer").pause();
				}
			}
		});	
		
		$('#newsSubmitFocus').hide();
		$('.champNews').focus(function() {  
			if (this.value == this.defaultValue){  
				this.value = '';  
			}  
			if(this.value != this.defaultValue){  
				this.select();  
			}  
		});  
		$('.champNews').blur(function() {  
			if (this.value == ''){  
				this.value = (this.defaultValue ? this.defaultValue : '');  
			}  
		});  
		

		// ==================================================================================================
		// Box newsletter	
		$('#newsForm').submit(function() 
		{  
			$.getJSON("../script/inscriptionNewsletter.php?q=" + $('#emailNewsletter').val(), function(data){
				$("#messageNewsletter").empty();
			
				if (data=="succes")
				{
					$('#emailNewsletter').val("");
					$("#messageNewsletter").animate({height:'25px'}, 400, function() {$("#messageNewsletter").append('<font color="green">Votre inscription est enregistr&eacute;e...</font>').hide().fadeIn(200);});
				}
				else  if (data=="existant")
				{
					$("#messageNewsletter").animate({height:'25px'}, 400, function() {$("#messageNewsletter").append('<font color="red">Adresse d&eacute;j&agrave; inscrite...</font>').hide().fadeIn(200);});
				}
				else  if (data=="nonValide")
				{
					$("#messageNewsletter").animate({height:'25px'}, 400, function() {$("#messageNewsletter").append('<font color="red">Adresse e-mail non valide...</font>').hide().fadeIn(200);});
				}

			});
			return false;
		});


		// ==================================================================================================
		// Box login espace membres		


		$(".coinChoriste").hover(function(){
			$(".accesEspaceMembre").css("background-position","0 -25px");
		},function(){
			if ( $('fieldset#signin_menu').is(':hidden') ) {
				$(".accesEspaceMembre").css("background-position","0 0");
			}
		});
		
		$("#accesEspaceMembre").click(function(e) {          
			e.preventDefault();
			if ( $('fieldset#signin_menu').is(':hidden') ) {
				$(".accesEspaceMembre").css("background-position","0 -25px");
				$("fieldset#signin_menu").fadeIn(200);
				$(".passwordEspaceMembre").focus();
			}
		});
		
		$("fieldset#signin_menu").mouseup(function() {
			return false;
		});
		
		$(document).mouseup(function(e) {
			if($(e.target).parent(".accesEspaceMembre").length==0) {
				$("fieldset#signin_menu").fadeOut(200);
				$(".accesEspaceMembre").css("background-position","0 0");
			}
		});	

		var loginTimers = [];  
		 $('#logoChoralia').hover(  
			function () {  
				var id = jQuery.data(this);  
				var $this = $(this);  
				loginTimers[id] = setTimeout(function() {
					$('#descriptionChoralia').fadeIn(100);
					loginTimers[id] = ""; 
				}, 200 );  
			},  
			function () {  
				var id = jQuery.data(this);  
				if (loginTimers[id] != "" ) {  
					clearTimeout( loginTimers[id] );  
				} else { 
					$("#descriptionChoralia").fadeOut(100);  
				}  
			}  
		);

		$('#signin').submit(function() 
		{  
			$('#remember').is(':checked') ? s=1 : s=0;
			
			var href = window.location.href;
			var tabSplitHref = href.split('/');
			nomDeDomaine = tabSplitHref[2];
			
			$.ajaxSetup({ cache: false });
			$.getJSON("http://" + nomDeDomaine + "/script/verifLoginEspaceMembre.php?s=" + s + "&q=" + $('#password').val(), function(data){
				accepteCookies = (navigator.cookieEnabled) ? true : false;
				if (accepteCookies) {
					if (data==1)
						document.location.replace($("#signin").attr("action"));
					else  if (data==0)
					{
						$("#erreurEspaceMembres").empty();
						$('#password').val("");
						$("#erreurEspaceMembres").animate({height:'25px'}, 400, function() {$("#erreurEspaceMembres").append('<p>Ce mot de passe est incorrect.</p>').hide().fadeIn(200);});
						$("#password").focus();
					}
				}
				else  
				{
					$("#erreurEspaceMembres").empty();
					$("#erreurEspaceMembres").animate({height:'45px'}, 400, function() {$("#erreurEspaceMembres").append('<p>Veuillez configurer votre navigateur pour qu\'il accepte les cookies.</p>').hide().fadeIn(200);});
					$("#password").focus();
				}
			});
			return false;
		});

		// ==================================================================================================
		// Box live search	
		
		document.searchForm.setAttribute( "autocomplete","off" );
		
		$('.champSearch').focus(function() {  
			if (this.value == this.defaultValue){  
				this.value = '';  
			}  
			if(this.value != this.defaultValue){  
				this.select();  
			}  
		});  
		$('.champSearch').blur(function() {  
			$("#autoComplete").fadeOut();
			if (this.value == ''){  
				this.value = (this.defaultValue ? this.defaultValue : '');  
			}  
		});
		
		function soumissionRecherche()
		{
			$(".searchForm").submit();
		}
		
		var delayKeyup = "";
		var autoSuggest = "";
		$("#listeResultats").append('<ul></ul>');
		$('.champSearch').keyup(function() 
		{  
			clearTimeout(autoSuggest);
			clearTimeout(delayKeyup);
			var search; 
   			search = $('.champSearch').val(); 
   			delayKeyup = setTimeout(function () {
				if (search.length > 2) // Si au moins 3 caract¸res saisis : Affichage de la box
				{
					$("#loaderSearch").fadeIn(200);
					$("#searchSubmit").fadeOut(200);

					// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
					// Affichage dynamique des rˇsultats 		
						$.ajaxSetup({ cache: false});			
						$.getJSON("../script/liveSearch.php", {q: $('.champSearch').val()},
						function(data) // "data" correspond au tableau JSON retournˇ par la page php de recherche
						{
							autoSuggest = setTimeout(function () {
								$("#autoComplete").fadeIn();
								$("#listeResultats ul li").remove();
								$.each(data[0].tuple, function(i) // Pour chaque ˇlˇment du rˇsultat de recherche ("i" reprˇsente le numˇro de ligne)
								{ 
									$("#listeResultats ul").append('<li><a href="' + data[0].tuple[i].url+ '" class="titreListeSearch"><img src="' + data[0].tuple[i].image + '"  class="imgSearch" /><span>' + data[0].tuple[i].titre + '</span><br />' + data[0].tuple[i].contenu + '</a></li>');
								});
			
								// -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
								// Contenu du bas de la box de recherche 		
								if (data[0].nbResultat == 0)
								{
									$("#listeResultats ul li").remove();
									$(".aucunResultat").remove();
									$("a.voirResultats").remove();
									$("#autoComplete").append('<div class="aucunResultat">Il n\'existe aucun r&eacute;sultat pour cette recherche...</div>');
								}
								else if (data[0].nbResultat == 1)
								{
									// $(".listeResultats ul li").remove();
									$(".aucunResultat").remove();
									$("a.voirResultats").remove();
									$("#autoComplete").append('<a href="' + data[0].tuple[0].url+ '" class="voirResultats">Voir le r&eacute;sultat</a>');
								}
								else
								{
									// $(".listeResultats ul li").remove();
									$(".aucunResultat").remove();
									$("a.voirResultats").remove();
									$("#autoComplete").append('<a href="../../?s=' + $('.champSearch').val() +'" class="voirResultats">Voir les ' + data[0].nbResultat + ' r&eacute;sultats</a>');
								}
								$("#searchSubmit").fadeIn(200);
								$("#loaderSearch").fadeOut(200);
							}, 500);
						});
				}
				else// Si moins de 3 caract¸res saisis : Disparition de la box
				{
					$("#autoComplete").fadeOut();
					$("#loaderSearch").fadeOut(200);
					$("#searchSubmit").fadeIn(200);
				}
			}, 400);
		});		
		
	});

	$().ready(function() {
		$('#coda-slider-1Index').codaSlider({
			autoSlide: true,
			autoSlideInterval: 6000,
			autoSlideStopWhenClicked: true
		});
		$('#coda-slider-1').codaSlider();
		$('#coda-slider-2').codaSlider();
		$('#coda-slider-111').codaSlider();
		$('#coda-slider-113').codaSlider();
		$('#coda-slider-213').codaSlider();
	});
	
	$(function() {
		$("#boxTabs").tabs();		
	});
	
jQuery(document).ready(function($) {  

	var navTimers = [];  
     $('#menu > li').hover(  
    	function () {  
        	var id = jQuery.data(this);  
			var $this = $(this);  
			navTimers[id] = setTimeout(function() {
				$this.find('ul').show();
				$this.find('a:first').addClass("hover");
				navTimers[id] = ""; 
			}, 200 );  
		},  
		function () {  
			var id = jQuery.data(this);  
			if (navTimers[id] != "" ) {  
				clearTimeout( navTimers[id] );  
			} else { 
					$(this).find("ul").hide(100);  
				$(this).find('a:first').removeClass("hover");
			}  
		}  
	);
	
     $('#listeTri').hover(  
    	function () {  
        	var id = jQuery.data(this);  
			var $this = $(this);  
			navTimers[id] = setTimeout(function() {
				$('div#listeTriContent').slideDown(300); 
				navTimers[id] = ""; 
				$('div#btonListeTri').addClass("btonListeTriHover");
			}, 200 );  
		},  
		function () {  
			var id = jQuery.data(this);  
			if (navTimers[id] != "" ) {  
				clearTimeout( navTimers[id] );  
			} else { 
				$('div#listeTriContent').hide(100);
				$('div#btonListeTri').removeClass("btonListeTriHover");
			}  
		}  
	);
});

