Effect.Execute = new Class.create()
Object.extend(Object.extend(Effect.Execute.prototype, Effect.Base.prototype), {
	initialize : function (callback) {
		this.callback = callback
		var options = Object.extend({
	 		
	    }, arguments[1] || {});
	    this.start(options);
	},
	setup : function () {},
	update : function () {},
	finish : function () {
		if ( this.callback )
			this.callback()
	}
});

var PairedShow = new Class.create()
PairedShow.prototype = {
	initialize : function (last,delay) {
		this.last = last
		this.delay = delay
		this.current = { e : 1 , o : 2 }

		this.queue = Effect.Queues.get('PairedShow');
		
		this.waitSwitch(3)
	},

	waitSwitch : function (i) {
		new Effect.Execute(
			this.doSwitch.bind(this,i),
			{
				duration : this.delay,
				queue : { position: 'end', scope: this.queue }
			}
		)
	},

	doSwitch : function (i) {
		// if i is too big, start over
		if ( i > this.last ) 
			i = 1

		// which show are we tracking?
		var c = (i%2) ? this.current.e : this.current.o

		var elc = $('slide'+c)
		var eln = $('slide'+i)

		// fade out old slide
		new Effect.Fade(elc,{
			duration : 2,
			queue : { position: 'end', scope: this.queue }
		})		

		// fade in new slide
		new Effect.Appear(eln,{
			duration : 2,
			queue : { position: 'end', scope: this.queue }
		})

		// set new slide as current
		if (i%2) {
			this.current.e = i
		} else {
			this.current.o = i
		}

		// set a timer to move on
		this.waitSwitch(i+1)
	}
}

1;
