function carousel(container){
  var deg = 0;
  var dif = 0.5;

  $(container).css("overflow", "hidden");
  $(container).find("div.stage").css("position", "relative");

  /* Assigning the buttons to a variable for speed and storing the length of 
     the array in a variable */
  var arr = $(container).find(".btn");
  var len = arr.length;

  // Finding the centers of the animation container
  var centerX = $(container).find("div.stage").width()/2 - 56;
  var centerY = $(container).find("div.stage").height()/2 - 55;

  // Applying absolute positioning to the buttons
  arr.css({ 
    position  : "absolute",
    top       : 0,
    left      : 0,
    float     : "left",
    display   : "none"
  });

  // The function inside the interval is run 25 times a second
  setInterval(function(){	
    // This forms an area with no activity in the middle of the stage
    if(Math.abs(dif)<0.08) return false;
    
    deg += dif; // Increment the degrees
    $.each(arr, function(i){
	    // Calculate the sine and cosine
	    var eSin = Math.sin(((360/len)*i+deg)*Math.PI/180);
	    var eCos = Math.cos(((360/len)*i+deg)*Math.PI/180);
	    
	    // Setting the css properties
	    $(this).css({
		    top     : centerY+20*eSin,      // 20  => la hauteur de l'élipse
		    left    : centerX+280*eCos,     // 280 => la largeur de l'elipse
		    opacity : 0.8+eSin*0.2,
		    zIndex  : Math.round(80+eSin*20)
	    }).css("display", "block");
    })
  }, 40);

  /* Detecting the movements on the mouse and speeding up or reversing the 
     rotation accordingly */	
  var over = false;

  $(container).find("div.stage").mousemove(function(e){
	  if(!this.leftOffset){
		  // This if section is only run the first time the function is executed
		  this.leftOffset = $(this).offset().left;
		  this.width      = $(this).width();
	  }
	
	  // If the mouse is over a button, set dif to 0, which stops the animation
	  if(over) dif = 0;
	  // In the other case calculate speed according to the X pos of the mouse
	  else dif = -0.5+(1*((e.pageX-this.leftOffset)/this.width));		
  });

  // Detecting whether the mouse is positioned above button
  $(container).find(".bcontent").hover(
	  function(){ over = true; dif = 0; },
	  function(){ over = false; }
  );
}

