   // slide show script v1.0
   // by j. pelosi 7/27/06
   // joe@illgraphs.com
   
   var obj;
			
		function SlideShow(){
		
			var currentFrame;
			var sliderTimeout;
			var start_frame;
			var end_frame;
			var fadeSpeed
			var delay;
			var interval;
			
			
			this.currentFrame = 1;
			this.fadeSpeed = 1.0;
		
		}
		
		SlideShow.prototype = {
	
			setDelay : function (milSecs){
				this.delay = milSecs;
			} 
			,
			setFrames : function (st, en){
				this.start_frame = st;
				this.end_frame = en;
			}
			,
			setFadeSpeed : function (speed){
				this.fadeSpeed = speed;
			}
			,
			changeSlide: function(dir){
			
				this.stop_slideshow()
				if (this.currentFrame == this.end_frame) { 
					this.currentFrame = this.start_frame; 
				} else { 
					this.currentFrame = this.currentFrame + 1; 
				}
				this.sliderTimeout = setTimeout(this.switch_slides (this.currentFrame, this.start_frame, this.end_frame, this.delay), this.delay); 
			
			}
			,
			switch_slides : function(dir) {
				
				
					//alert(this.currentFrame+", "+this.delay+", "+this.end_frame+", "+this.start_frame);
					//Element.hide('slideshow' + this.currentFrame);
					//Effect.SlideRightOutOfView('slideshow' + this.currentFrame);
					Effect.Fade('slideshow' + this.currentFrame, { duration: this.fadeSpeed });
					if (dir == -1){
						if (this.currentFrame == this.start_frame) { 
							this.currentFrame = this.end_frame; 
						} else { 
							this.currentFrame = this.currentFrame - 1; 
						}
					
					} else {
						if (this.currentFrame == this.end_frame) { 
							this.currentFrame = this.start_frame; 
						} else { 
							this.currentFrame = this.currentFrame + 1; 
						}
					}
					//alert(this.currentFrame+", "+this.delay+", "+this.end_frame+", "+this.start_frame);
					
					//setTimeout("Effect.SlideRightIntoView('slideshow" + this.currentFrame + ");", 1100);
					setTimeout("Effect.Appear('slideshow" + this.currentFrame + "', { duration: " + this.fadeSpeed + " });", this.fadeSpeed*1000);
					//Effect.Appear('slideshow' + this.currentFrame, { duration: 0.5 });
					//setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 850);
					//Effect.Appear('slideshow' + this.currentFrame);
					//Element.show('slideshow' + this.currentFrame);
					//this.sliderTimeout = setTimeout(this.switch_slides(), this.delay);
				
			}
			,
			start_slideshow : function ()	{
				//alert(this.delay)
				//this.sliderTimeout = setTimeout(this.switch_slides(), this.delay);
				obj = this;
				slides = $('slides');
				slides.onmouseover = function(){
					obj.stop_slideshow();
					slides.className = "overState";
				}
				slides.onmouseout = function(){
					obj.resume_slideshow();
					slides.className = "";
				}
				
				this.interval = setInterval('obj.switch_slides()', this.delay);
			}
			,
			resume_slideshow : function(){
				this.interval = setInterval('obj.switch_slides()', this.delay);
			}
			,
			stop_slideshow : function ()	{
				//alert(obj.sliderTimeout);
				clearInterval(this.interval);
				//alert(this.sliderTimeout);
			}
			,
			newSlide : function (dir){
				this.stop_slideshow();
				this.switch_slides(dir);
				this.resume_slideshow();
			}
	
	}
	
	
/*Effect.SlideRightIntoView = function(element) {
  $(element).style.width = '0px';
  $(element).style.overflow = 'hidden';
  //$(element).firstChild.style.position = 'relative';
  Element.show(element);
  new Effect.Scale(element, 100,
    Object.extend(arguments[1] || {}, {
      scaleContent: false,
      scaleY: false,
      scaleMode: 'contents',
      scaleFrom: 0,
      afterUpdate: function(effect){}
    })
  );
}

Effect.SlideRightOutOfView = function(element) {
  $(element).style.overflow = 'hidden';
  //$(element).firstChild.style.position = 'relative';
  Element.show(element);
  new Effect.Scale(element, 0,
    Object.extend(arguments[1] || {}, {
      scaleContent: false,
      scaleY: false,
      afterUpdate: function(effect){},
      afterFinish: function(effect)
        { Element.hide(effect.element); }
    })
  );
}

Effect.SlideLeftAndRight = function(element) {
  element = $(element);
  if(Element.visible(element)) new Effect.SlideRightOutOfView(element);
  else new Effect.SlideRightIntoView(element);
}
Effect.DropIn = function(element) {
  element = $(element);
  var oldTop = element.style.top;
  var oldLeft = element.style.left;
  var pos = Position.cumulativeOffset(element);
   return new Effect.Parallel(
    [ new Effect.MoveBy(element, 100, 0, { sync: true }), 
      new Effect.Opacity(element, { sync: true, from:0.0, to: 1.0 }) ],
    Object.extend(
      { duration: 0.5,
        beforeSetup: function(effect) { 
          Element.makePositioned(effect.effects[0].element); 
          Element.setOpacity(element, 0);
          element.style.position = 'absolute'; 
          element.style.top = (pos[1]-100) + 'px'; 
        }
      }, arguments[1] || {}));
}
*/
function iniSlideShow(totalSlides, fadeSpeed, delay){
	$('slideshow1').style.display = 'block';
	mySlide = new SlideShow();
	mySlide.setDelay(delay);
	mySlide.setFrames(1,totalSlides);
	mySlide.setFadeSpeed(fadeSpeed);
	mySlide.start_slideshow();
}
			

