(function () {
	YAHOO.util.Event.onDOMReady(function() {
		YAHOO.widget.Carousel.prototype.CONFIG.MAX_PAGER_BUTTONS = 20;
		
		// no keyboard handling (needed to fill subscription form)
		YAHOO.widget.Carousel.prototype._keyboardEventHandler = function (ev) {};
      
		// Hide the loading mask
      YAHOO.util.Dom.get('slidesMask').style.display = 'none';

		// Instanciate and show the carousel
      YAHOO.util.Dom.get('slides').style.visibility = 'visible';
		var carousel = new YAHOO.widget.Carousel("container", { numVisible: 1, animation: { speed: 0.5 } });
		carousel.render();
		carousel.show();
      
      // Event tracking pour google analytics
      carousel.on('afterScroll', function(slides) {
         var action = window.location.pathname.substr(1);
			if( action === "") { action = "home"; }
         //pageTracker._trackEvent("slides", action, ""+slides.first,1);
			pageTracker._trackPageview("/slides/"+action+"/"+slides.first);
      });
      
		// Prevent the focusing on the slide when clicking on an input (except checkboxes otherwise we can't click on them)
		var fields = YAHOO.util.Dom.getElementsBy( function(o) {return o.type !== "checkbox";}, 'input' , 'container').concat(YAHOO.util.Dom.getElementsBy( function() {return true;}, 'select' , 'container'));
		if(fields.length > 0) {
			YAHOO.util.Event.addListener(fields, 'click', function(e) { YAHOO.util.Event.stopEvent(e); });
		}
		
	});
	
})();