// Easing du menu, d'apres le plugin jquery.easing
// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend( jQuery.easing,
{
easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}
});
/* Tooltip fontions */
  this.tooltip = function(){	
		// determine la distance du tooltip par rapport a la souris	
		xOffset = 0;
		yOffset = 20;		

	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
 
 /* ----- initialisation des scripts ----- */
$(document).ready(function(){
$("#tranches").fadeIn(500);
/* tooltip */
tooltip();

/* div invisibles */
	$(".sarah").mouseenter(function () {
			$("#sarah").fadeIn(200);
	});
	$(".sarah").mouseleave(function () {
			$("#sarah").fadeOut(200);
	});
/* ----------- */	
	$(".marion").mouseenter(function () {
			$("#marion").fadeIn(200);
	});
	$(".marion").mouseleave(function () {
			$("#marion").fadeOut(200);
	});	
/* ----------- */		
	$(".contact").click(function () {
		if ($("#contact").is(":hidden")) {
			$("#contact").fadeIn(200);
			$("#ecrits").fadeOut(200);
		}
		else {
			$("#contact").fadeOut(200);
		}
	});
/* ----------- */	
	$(".ecrits").click(function () {
		if ($("#ecrits").is(":hidden")) {
			$("#ecrits").fadeIn(200);
			$("#contact").fadeOut(200);
		}
		else {
			$("#ecrits").fadeOut(200);
		}
});
/*  accordeon */
$('.accordeon').hide(); // on cache tous les textes (blocs ayant la classe accordeon)
  $('.accordeon-first').show(); // on cache tous les textes (blocs ayant la classe accordeon)
  $('h3').click(function() { // si on clique sur un titre (ici tous les ˇlˇments contenu en les balises h4)
  $(this).addClass("courant").siblings().removeClass("courant");
    $(this).next('div:hidden').show() // on deroule le div cachˇ qui suit directement le titre
   .siblings('div:visible').hide();
     // et on cache les div similaires qui etait visible

});
/* cadre selection miniature */
$('ul#miniatures-lien img').click(function() {
$('ul#miniatures-lien img').removeClass("selection");
$('ul.miniatures li a').removeClass("active");
$(this).addClass("selection");
$('ul.miniatures li h3 a.premier').addClass("active"); /*premier en rouge */
$('.accordeon').hide();
$('.accordeon-first').show();
$('.accordeon-first').show();
});
/* onglets */
 $(".tab").hide();

 //pour internet explorer
 $("#menu .tab:first").hide();
 $(".tab:first").show();

 //when we click one of the tabs
 $(".htabs a").click(function(){
 //get the ID of the element we need to show
 stringref = jQuery(this).attr("href").split('#')[1];
 //hide the tabs that doesn't match the ID
 $('.tab:not(#'+stringref+')').hide();
  //fix
  /*cree la class pour le texte*/

 if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
 $('.tab#' + stringref).show();
 }
 else
 //display our tab fading it in
 $('.tab#' + stringref).fadeIn();
  //stay with me
 return false;

 });
});