
var SlideShow = Class.create({
  initialize: function(ID,ObjectName,start_frame,delay) {
    this.delay=delay;
    this.start_frame=start_frame;
    this.ID=ID;
    this.Paused=0; 
    this.frame=start_frame
    this.objectName=ObjectName;
    
    this.lis = $(ID).childElements();
    	
	    for( i=0; i < this.lis.length; i++)
	    {
		    if(i!=this.start_frame)
		    {
			    this.lis[i].style.display = 'none';
		    }
	    }
	    this.end_frame = this.lis.length -1;
    	
    	
    	var eventstring='<script>Event.observe($("' + this.ID +'"), "mouseover", function() {' + this.objectName + '.pause();});';
        eventstring=eventstring + 'Event.observe($("' + this.ID +'"), "mouseout", function() {' + this.objectName + '.unpause();});</script>';

		


    	eventstring.evalScripts();
        setTimeout(this.objectName + ".fadeInOut_slideshow()", this.delay);		
    
  },
    fadeInOut_slideshow: function () {
        if (this.Paused==0)
        {
			this.forward() ; 

		}
		setTimeout(this.objectName + ".fadeInOut_slideshow()", this.delay);		
   },
	pause: function () {
	    this.Paused=1;
	    
	},
	unpause: function () {
	    this.Paused=0;
	},
	forward: function () {
			this.pause();
			Effect.Fade(this.lis[this.frame]);
		    if (this.frame == this.end_frame) { this.frame = this.start_frame; } else { this.frame=this.frame+1; }
		    lisAppear = this.lis[this.frame];
		    Effect.Appear(lisAppear)
		    this.unpause();
	},
	back: function () {
			this.Paused=1;
			Effect.Fade(this.lis[this.frame]);
		    if (this.frame == this.start_frame) { this.frame = this.end_frame; } else { this.frame=this.frame-1; }
		    lisAppear = this.lis[this.frame];
		    Effect.Appear(lisAppear)
	}
        
});

