window.addEvent('domready',function(){var showDuration=5500;var container=$('slideshow-container');var images=container.getElements('img');var container2=$('thumb_div');var images2=container2.getElements('img');var currentIndex=0;var interval;var toc=[];var tocActive='toc-active';var thumbOpacity=0.5;var captionDIV=new Element('div',{id:'slideshow-container-caption',styles:{opacity:thumbOpacity}}).inject(container);var captionHeight=captionDIV.getSize().y;captionDIV.setStyle('height',0);var start=function(){interval=show.periodical(showDuration);};var stop=function(){$clear(interval);};var show=function(to){images[currentIndex].fade('out');toc[currentIndex].removeClass(tocActive).fade(thumbOpacity);images[currentIndex=($defined(to)?to:(currentIndex<images.length-1?currentIndex+1:0))].fade('in');toc[currentIndex].addClass(tocActive).fade(1);captionDIV.set('tween',{onComplete:function(){captionDIV.set('tween',{onComplete:$empty}).tween('height',captionHeight);var title='';var captionText='';var captionLink='';if(images[currentIndex].get('alt')){cap=images[currentIndex].get('alt').split('::');title=cap[0];captionText=cap[1];captionLink=cap[2];captionDIV.set('html','<a href="'+captionLink+'"><h3>'+title+'</h3>'+(captionText?'<p>'+captionText+'</p></a>':''));}}}).tween('height',0);};var preview=new Element('div',{id:'slideshow-container-controls'}).inject(container,'after');images.each(function(img,i){toc.push(new Element('img',{src:images2[i].get('src'),title:img.get('alt'),styles:{opacity:thumbOpacity},events:{click:function(e){if(e)e.stop();stop();show(i);start();},mouseenter:function(){this.fade(1);},mouseleave:function(){if(!this.hasClass(tocActive))this.fade(thumbOpacity);}}}).inject(preview));if(i>0){img.set('opacity',0);}});container.addEvents({mouseenter:function(){stop();},mouseleave:function(){start();}});window.addEvent('load',function(){show(0);start();});});
