function PodSlideshow(id, slides, options){
	var nextIndex = 0;
	var timer = 0;
	var parts = id.split("_");
	var podID = parts[1];
	var currentSlide = -1;
	var opacityChange;
	var durationSpeed = 400;
	
	function init(){
		slides = slides.split(",");
		
		if(options["randomOrder"] == 1){
			slides.sort(randOrd);
		}
		
		// if show buttons is selected and there is more than one slide
		if(options["buttons"] == 1 && slides.length > 1){
			var buttons = document.createElement("div");
			buttons.className = "buttons";

			for(var i = 1; i <= slides.length; i++){
				var a = document.createElement("a");
				a.innerHTML = i;
				a.rel = i - 1;
				a.href = "#";
				a.id = "slideshow_" + podID + "_" + i;

				a.onclick = function(){
					clearTimeout(timer);
					nextIndex = this.rel;
					next_slide();
				};

				buttons.appendChild(a);
			}
			$(id).appendChild(buttons);
		}
		next_slide();
	}
	
	function next_slide(){
		show_slide(nextIndex);
	}
	
	function show_slide(index){
		index = parseInt(index);
		if(currentSlide > -1){
			clearTimeout(timer);
			//alert(currentSlide);
			opacityChange = new Fx.Style(slides[currentSlide], 'opacity', {duration:durationSpeed});
			opacityChange.start(0).chain(function(){
				$(slides[currentSlide]).style.display = "none";
				if(options["buttons"] == 1 && slides.length > 1){
					$("slideshow_" + podID + "_" + (currentSlide + 1)).className = "";
				}
				opacityChange = new Fx.Style(slides[index], 'opacity', {duration:durationSpeed});
				opacityChange.set(0);
				$(slides[index]).style.display = "block";
				opacityChange.start(1).chain(function(){
					timer = setTimeout(next_slide, options["delay"]);
					if(options["buttons"] == 1 && slides.length > 1){
						//alert("slideshow_" + podID + "_" + (index + 1))
						$("slideshow_" + podID + "_" + (index + 1)).className = "current";
						
					}
					nextIndex = (nextIndex + 1 < slides.length ? nextIndex + 1 : 0);
					currentSlide = index;
				});
			});
		}else{	// if the first time, just fade in the new slides
			opacityChange = new Fx.Style(slides[0], 'opacity', {duration:durationSpeed});
			opacityChange.set(0);
			$(slides[0]).style.display = "block";
			opacityChange.start(1).chain(function(){
				if(slides.length > 1){
					timer = setTimeout(next_slide, options["delay"]);
				}
				
				if(options["buttons"] == 1 && slides.length > 1){
					$("slideshow_" + podID + "_1").className = "current";
				}
				nextIndex = (nextIndex + 1 < slides.length ? nextIndex + 1 : 0);
				currentSlide = index;
			});
		}
		
		
	}
	
	function randOrd(){
	return (Math.round(Math.random())-0.5); }
	
	// run the constructor
	init();
}
