   var stopSlideshow = false;
   var selectedPhoto = 0;
   var transitionSpeed = 3000;
   var slideshowEffects = new Array();
   var numberRegExp = /(\d+)$/;

    function fadeIn(effects) {
      if(effects) {
        effects.start({
         'opacity': 1
        });
      }
    }

    function fadeOut(effects) {
      if(effects) {
        effects.start({
         'opacity': 0
        });
      }
    }

	function slideshow() {
		if(stopSlideshow) {
			return;
		}
	
		var photo = selectedPhoto + 1
		if(photo == numPics) {
			photo = 0;
		}
			
		fadeOut(slideshowEffects[selectedPhoto]);
		fadeIn(slideshowEffects[photo]);
		
		selectedPhoto = photo;

		setTimeout('slideshow()', 10000);
	}
		
    function createSlideshow(numPics, picId, selectId) {
   		for(var i = 0; i<numPics; i++) {
   			slideshowEffects[i] = new Fx.Styles(picId+i, {duration: transitionSpeed, transition: Fx.Transitions.Sine.easeInOut});

			var selectImg = $(selectId+i);
			if(selectImg) {   			
	   			selectImg.addEvent('click', function(e){
	              new Event(e).stop();
	
	              fadeOut(slideshowEffects[selectedPhoto]);
	              var match = numberRegExp.exec(this.id);
	              selectedPhoto = match[1];
		          fadeIn(slideshowEffects[selectedPhoto]);
		          
		          stopSlideshow = true;
	            });
            }
   		}
		setTimeout('slideshow()', 10000);
	}
		