var Slideshow = new Class({
	options: {
		active: 0,
		active2: 0,
		delay: 10000
	},
	
	initialize: function(gallery, height, gallery2, height2){
		this.tg = gallery;
		this.tg2 = gallery2;
		this.height = height;
		this.height_a = 0;
		this.gallery_a = $(gallery);
		this.gallery = $(gallery);
		this.images = this.gallery.getElements('img');
		this.length = this.images.length;
		this.height2 = height2;
		this.height2_a = 0;
		this.gallery2_a = $(gallery2);
		this.gallery2 = $(gallery2);
		this.images2 = this.gallery2.getElements('img');
		this.length2 = this.images2.length;
		this.setup();
	},
	
setup: function(){
	this.getPositions(this.length, this.length2);
	this.slideImageFX = new Fx.Scroll(this.gallery, {});
	this.slideImageFX2 = new Fx.Scroll(this.gallery2, {});
	this.timer = this.next.periodical(this.options.delay, this);
},

next: function(){
	if ((typeof show == 'undefined') || show == 0) {
		(this.options.active == this.length-1) ? this.options.active = 0 : this.options.active += 1;
		(this.options.active2 == this.length2-1) ? this.options.active2 = 0 : this.options.active2 += 1;
		this.slideImageFX.start(this.imagePositions[this.options.active].x, this.imagePositions[this.options.active].y);
		this.slideImageFX2.start(this.imagePositions2[this.options.active2].x, this.imagePositions2[this.options.active2].y);
		if ((this.options.active == this.length-1)) {
			var myFunction = function(){
				this.slideImageFX.set(0, 0);
				this.options.active = 0;
			};
			myFunction.delay(1100, this);
		}
		
		if ((this.options.active2 == this.length2-1)) {
			var myFunction2 = function(){
				this.slideImageFX2.set(0, 0);
				this.options.active2 = 0;
			};
			myFunction2.delay(1100, this);
		}
	}
},

	getPositions: function(size, size2){
		this.imagePositions = [];
		for(var i = 0; i < size; i++){
			this.imagePositions[i] = this.images[i].getPosition(this.gallery);
		}
		this.imagePositions2 = [];
		for(var i = 0; i < size2; i++){
			this.imagePositions2[i] = this.images2[i].getPosition(this.gallery2);
		}
	}
});
