/* code pour jQuery */
$(document).ready(function() {


	// animation du menu principal (accordéon)
	$('.sub').hide();
	$('.active + .sub').show();
	// version sans animation, pour IE7 (sinon gros bug d'affichage)
	if(($.browser.msie) && ($.browser.version == "7.0")){
		$('#menu li:has(ul) > a').click(function (event) {
			if ($(this).next()[0].style.display == 'none') {
				$('.sub').hide();
				$(this).next().toggle();
			} else {
				$('.sub').hide();
			}
			$(this).blur();
			event.preventDefault();
		})
	// version avec animation, pour les autres navigateurs
	} else {
		$('#menu li:has(ul) > a').click(function (event) {
			if ($(this).next()[0].style.display == 'none') {
				$('.sub').animate({height: 'hide'}, 300);
				$(this).next().animate({height: 'toggle'}, 300);
			} else {
				$('.sub').animate({height: 'hide'}, 300);
			}
			$(this).blur();
			event.preventDefault();
		})
	}

	// slideshow sur la page d'accueil
	$('.home #slideshow').show();
	$('.home #slideshow').innerfade({
		animationtype: 'fade', 
		speed: 1000, 
		timeout: 3000, 
		type: 'random' 
	});

	// "crypter" les adresses e-mail
	// Pour tous les liens commençant par "mailto" ou les span ayant une class "wmail"
	// remplace "[arobase]" par "@" et "[point]" par "."
	$('a[href^="mailto"], span.wmail').each(function (i) {
			//Remplacment du texte dans l'élément
			var temp = $(this).html();
			temp = temp.replace("[arobase]","@");
			temp = temp.replace("[point]",".");
			$(this).html(temp);
			//Si il y a un attribut "href", on remplace le texte dans l'attribut
			if($(this).attr("href")){
					var temphref = $(this).attr("href");
					temphref = temphref.replace("[arobase]","@");
					temphref = temphref.replace("[point]",".");
					$(this).attr("href",temphref);
			}
	})

}); // fin jQuery
