jQuery.noConflict();

jQuery(document).ready(function(){
	showImageLink();
	coverflowPrincipal();
	coverflowHoverLudo();
	coverflowCulture();
	jQuery("#sliderSelectionEdito").easySlider({
		auto: false,
		continuous: true
	});
	jQuery(".objetContainer > li > a").tipsy({fade: true});
	showMiseAvant();
});

function showMiseAvant()
{
	var nbSlide = 0;
	jQuery('.ressourceAssoc').each(function(index) {
		nbSlide = nbSlide + 1;
	});
	nombre = Math.floor(Math.random() * nbSlide)+1;
	suivant = nombre + 1;
	if (nombre == nbSlide)
	{
		suivant = 1;
	}
	var i = 0;
	jQuery('.ressourceAssoc').each(function(index) {
		i = i + 1;
		if (i == nombre)
		{
			jQuery(this).show();
			if (nombre < suivant)
			{
				jQuery(this).addClass("firstMiseEnAvant");
			}
		}
		if (i == suivant)
		{
			jQuery(this).show();
			if (suivant < nombre)
			{
				jQuery(this).addClass("firstMiseEnAvant");
			}
		}
	});
}

function coverflowPrincipal()
{
	jQuery("#coverflowRessourceSliderContainer").coverflowCurio({
		width:"592"
	});
}

function showImageLink(){
	jQuery('.right').mouseover(function(){
		jQuery(this).attr("src","/_assets/images/hp/next-ON.png");
	});
	jQuery('.right').mouseout(function(){
		jQuery(this).attr("src","/_assets/images/hp/next-OFF.png");
	});
};

function coverflowCulture(){
	jQuery('.RessourcePillier').mouseenter(function() {
		   var idToShow = this.id.split("_");
	  	   idToShow = idToShow[1];
		  jQuery("#coverfowTextInfo_" + idToShow).animate({
		    opacity: 0.7
		  }, 50, function() {
		  // Animation complete.
		  });
		  jQuery("#coverfowTextInfo_" + idToShow).slideDown("fast");
		});
		jQuery('.RessourcePillier').mouseleave(function() {
		  jQuery(".coverfowTextInfo").slideUp("fast");
		});
};

function coverflowHoverLudo(){
	jQuery('.sliderLudo > ul > li').live("mouseenter", function () { 
		var idToShow = this.id.split("_");
		  idToShow = idToShow[1];
		  jQuery(".coverfowTextInfo_" + idToShow).animate({
		    opacity: 0.7
		  }, 50, function() {
		  // Animation complete.
		  });
		  jQuery(".coverfowTextInfo_" + idToShow).slideDown("fast");
	});
	jQuery('.sliderLudo > ul > li').live("mouseleave", function () { 
		var idToShow = this.id.split("_");
		  idToShow = idToShow[1];
		  jQuery(".coverfowTextInfo_" + idToShow).slideUp("fast");
	});
};
/*
function coverflowHoverLudo(){
	jQuery('.coverfowTextInfoContainer').mouseenter(function() {
	  var idToShow = this.id.split("_");
	  idToShow = idToShow[1];
	  jQuery(".coverfowTextInfo_" + idToShow).animate({
	    opacity: 0.7
	  }, 50, function() {
	  // Animation complete.
	  });
	  jQuery(".coverfowTextInfo_" + idToShow).slideDown("fast");
	});
	jQuery('.coverfowTextInfoContainer').mouseleave(function() {
	  var idToShow = this.id.split("_");
	  idToShow = idToShow[1];
	  jQuery(".coverfowTextInfo_" + idToShow).slideUp("fast");
	});
};
*/
   // Credits: Robert Penners easing equations (http://www.robertpenner.com/easing/).
  jQuery.easing["BounceEaseOut"] = function(p, t, b, c, d) {
    if ((t/=d) < (1/2.75)) {
      return c*(7.5625*t*t) + b;
    } else if (t < (2/2.75)) {
      return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
    } else if (t < (2.5/2.75)) {
      return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
    } else {
      return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
    }
  };

  // Carousel ludo
  jQuery(function() {
    jQuery(".sliderLudo").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        visible: 4,
      animation: 500,
      mouseWheel: true,
      speed: 500
    });
  });

