vanilla.namespace('alteneve');

alteneve.slideshow =
{
    createSlideshow : function(container, slideURL)
    {
	var slideshow = new vanilla.toolkit.slide.Show(container, wisy.plugins.media.slider._createSlideByType.bind(wisy.plugins.media.slider, slideURL));
        slideshow.setTransition(new vanilla.toolkit.slide.FadingTransition());

	// bind controller
	EL('slideshow-control-previous').onclick = function()
	{
	    slideshow.previous(); 
	    return false;
	};

	EL('slideshow-control-next').onclick = function()
	{
	    slideshow.next(); 
	    return false;
	};

	// manage description
	slideshow.onNextSlide.subscribe
	(
	    function(slide)
	    {
		// on recherche le contenu
		Arr(slide.container.getElementsByTagName("div")).forEach
		(
		    function(div)
		    {
			if ( vanilla.html.DOM.hasClassName(div, "description") )
			{
			    EL("zone-description").innerHTML = div.innerHTML.replaceAll("<br>", " ");
			}
		    }
		);
	    }, 
	    this
	);

	return slideshow;
    }
}
