// JavaScript Document
//v1.0.1
/*

*/

var slideup = Class.create();
slideup.prototype = {
	initialize: function(id,images,slide_speed,fade_speed) {
		this.name=id;
		this.id  = $(id);
		this.images  = images;
		this.slide_speed  = slide_speed;
		this.fade_speed  = fade_speed;
		this.current = 0;
		this.next = 0;
		this.end = this.images.length-1;
		//this.timer= null;
		this.started=false;
		
		//this.preload();
		
		this.divCreate();
		
		this.play();
	},
	
	divCreate: function(){
		document.imageArray = new Array(this.images.length);

		for(x=0;x<=this.images.length-1;x++){
			
			document.imageArray[i] = new Image;
		
			document.imageArray[i].src = this.images[x];
			
			img = document.createElement('img');
			img.src = this.images[x];
			
			inner = document.createElement('div');
			inner.appendChild(img);
			this.images[x] = document.createElement('div');
			this.images[x].appendChild(inner);
			this.images[x].style.zIndex=1;
			Element.extend(this.images[x]);
			this.images[x].hide();
			this.id.appendChild(this.images[x]);

		}
	},

	play: function() {
		thisObject=this;
		
		if(this.end){
			
			slide_speed=this.slide_speed;

			if(this.started){
				setTimeout('thisObject.swap()',(slide_speed*1000));
			}else{
				this.started=true;
				this.swap();	
			}
			
		}
	},
	
	getNext: function() {
		this.current=this.next;
		this.next++;
		if(this.next>this.end)
			this.next=0;
	},
	
	swap: function() {
		thisObject=this;
		slide_speed=this.slide_speed;
		this.getNext(); 
		
		this.images[this.current].show();
		this.images[this.current].setStyle({
		  opacity: 1,
		  zIndex: 2,
		  position: 'relative',
		  top: 0,
		  display: 'block'
		});
		
		this.images[this.next].show();
		this.images[this.next].setStyle({
		  opacity: 1,
		  zIndex: 1,
		  position: 'absolute',
		  top: 0,
		  display: 'block'
		});

		/*new Effect.SlideUp(this.images[this.current], { duration: (slide_speed/4)*3, to: 0.75, from: 0.0, afterFinishInternal: '',transition: Effect.Transitions.linear, queue: 'end' });
		new Effect.Parallel(
			[ 
  			  //new Effect.SlideUp(this.images[this.current], { sync: true, to: 1.0, from: 0.0, transition: Effect.Transitions.linear }), 
			 new Effect.SlideUp(this.images[this.current], { sync: true, to: 1.0, from: 0.75, transition: Effect.Transitions.linear }), 
			 new Effect.Opacity(this.images[this.current], { sync: true, to: 0.0, from: 1.0 } )
			],
			{ duration: (slide_speed/4), afterFinish: thisObject.play(), queue: 'end' }
		);*/
		new Effect.SlideUp(this.images[this.current], { duration: slide_speed, to: 1.0, from: 0.0,transition: Effect.Transitions.linear, afterFinish: thisObject.play() });
	}

};