window.addEvent('domready',function() {
  /* settings */
  
  //var showDuration = 300;
  var container = $('slideshow-container');
  var images = container.getElements('img');
  var currentIndex = 0;
  var interval;
  //var toc = [];
  //var tocWidth = 20;
  //var tocActive = 'toc-active';
  
  /* new: starts the show */
  var start = function() { interval = show.periodical(showDuration); };
  var stop = function() { $clear(interval); };
  /* worker */
  var show = function(to) {
    images[currentIndex].fade('out');
    //toc[currentIndex].removeClass(tocActive);
    images[currentIndex = ($defined(to) ? to : (currentIndex < images.length - 1 ? currentIndex+1 : 0))].fade('in');
    //toc[currentIndex].addClass(tocActive);
  };
  
  images.each(function(img,i){
   if(i!=0) {
     img.fade('out')
   }
 });
 
 
 
  var container1 = $('slideshow-container1');
  var images1 = container1.getElements('img');
  var currentIndex1 = 0;



  /* worker */
  var show1 = function(to) {
    images1[currentIndex1].fade('out');
    images1[currentIndex1 = ($defined(to) ? to : (currentIndex1 < images1.length - 1 ? currentIndex1+1 : 0))].fade('in');
  };
  
  images1.each(function(img,i){
   if(i!=0) {
     img.fade('out')
   }
 });
  
  
  $$(".next1 a").addEvent("click", function(e){
        //e.preventDefault();
		if(e) e.stop();
        stop(); show1();
		//alert('test');
      
    })
  
	
	
  $$(".previous1 a").addEvent("click", function(e){
        if(e) e.stop();
        stop(); show1(currentIndex1 != 0 ? currentIndex1 -1 : images1.length-1);
      
    })
	
	
	$$(".next a").addEvent("click", function(e){
        //e.preventDefault();
		if(e) e.stop();
        stop(); show();
		//alert('test');
      
    })
  
	
	
  $$(".previous a").addEvent("click", function(e){
        if(e) e.stop();
        stop(); show(currentIndex != 0 ? currentIndex -1 : images.length-1);
      
    })
  
});
