
//	<div id="Slideshow" style="position:absolute;">
//		<div id="Slide1" style="position:absolute;top:0;left:0;display:none;"><img src="jpg/waiting-for-the-punchline.jpg" height="500" width="500" /></div>
//		<div id="Slide2" style="position:absolute;top:0;left:0;display:none;"><img src="jpg/appetite-for-destruction.jpg" height="500" width="500" /></div>
//		<div id="Slide3" style="position:absolute;top:0;left:0;display:none;"><img src="jpg/blood-sugar-sex-magic.jpg" height="500" width="500" /></div>
//	</div>
//	<script type="text/javascript" language="javascript">new htSlideshow({version:1,container:'Slideshow'});</ script>


	var htSlideshow = Class.create({
	
		initialize:function(options){
		
			ht = this;
		
			ht.options = {
			
				//set the version
				version		:	1,
				container	:	'SlideshowHolder',
				randomStart	:	true,
				randomSlide	:	false,
				delay		:	3,
				transDelay	:	1.5
			
			};
			Object.extend(ht.options, options || { });

			//setup the slideshow
			ht.setup(); 
		},
		
		//setup version 1
		setup:function(options){
		
			//create the object
			ht 	= this;
			hto = ht.options;
				
			//version 1
			if(hto.version == 1){		
				//create an array of the divs in the parent container
				hto.arrSlides = $$('#' + hto.container + ' div');
				
				//set the current slide to nothing
				hto.slideCurrent = '';
				
				//loop through and get the current showing slide!
				hto.arrSlides.each(function(item,index){
					//set the current slide
					if(item.style.display != 'none' && hto.slideCurrent == ''){
						hto.slideCurrentIndex 	= index;
						hto.slideCurrent 		= item;
					} else {
						item.setStyle({
							display:'block',
							opacity:0,
							filter:'alpha(opacity=0)'
						});
					}
				});
				
				//if there's no slide...choose one!
				if(hto.slideCurrent == ''){
					if(hto.randomStart==true){				
						hto.slideCurrentIndex = Math.floor(Math.random()*hto.arrSlides.length);
					} else {
						hto.slideCurrentIndex = 0
					}
					hto.slideCurrent = hto.arrSlides[hto.slideCurrentIndex];
					new Effect.Opacity(hto.slideCurrent,{from:0,to:1,duration:hto.transDelay})
				} 
				
				//start the slideshow!
				ht.startSlideshow(hto);
			} 						
			
			
		},
		
		
		startSlideshow:function(){
			
			//create the object
			ht 	= this;
			hto = ht.options
			
			hto.pe = new PeriodicalExecuter(ht.nextSlide.bind(ht),(hto.delay + hto.transDelay));
		},
		
		nextSlide:function(){
		
			//create the object
			ht 	= this;
			hto = ht.options
					
			if(hto.randomSlide==true){
				hto.slideNextIndex = Math.floor(Math.random()*hto.arrSlides.length);			
			} else {
				//increment the slide next index
				hto.slideNextIndex = hto.slideCurrentIndex+1;

				//check we're not outwith the arr length
				if(hto.slideNextIndex >= hto.arrSlides.length){
					hto.slideNextIndex = 0;
				}				
			}

			
			hto.slideNext = hto.arrSlides[hto.slideNextIndex];
			
			//fade out the current slide and fade in the new slide
			new Effect.Opacity(hto.slideCurrent,{from:1,to:0,duration:hto.transDelay})
			new Effect.Opacity(hto.slideNext,{from:0,to:1,duration:hto.transDelay})

			hto.slideCurrent 		= hto.slideNext;
			hto.slideCurrentIndex 	= hto.slideNextIndex;
		}
	});

