var Slideshow = {
	lastimage: null,
	ids: null,
	
	init: function() {
		this.ids = $A(arguments);
		this.lastimage = new Hash();
		
		this.ids.each(function(v, k) {
			this.lastimage.set(v);
			this.lastimage[v] = 0;
		}.bind(this));
		window.setTimeout("Slideshow.start()", 5000);
	},
	
	start: function() {
		this.ids.each(function(v, k) {
			this.slideshow(v);
		}.bind(this));
		window.setTimeout("Slideshow.start()", 5000);
	},
	
	slideshow: function(id) {
		var el = $$(id + ' img');
		if (el.length <= 1) return;
		
		var slide = false;
		
		if (this.lastimage[id] == 'reset') {
			Effect.toggle(el[el.length-1], 'appear', {duration: 2, queue: id});
			Effect.toggle(el[0], 'appear', {duration: 2, queue: id});
			this.lastimage[id] = 0;

		} else {
		
		el.each(function(v, k) {
			if (slide) {
				Effect.toggle(v, 'appear', {duration: 2, queue: id});
				this.lastimage[id] = el.length <= k + 1 ? 'reset' : k;
				throw $break;
			}
			if (this.lastimage[id] == k) {
				Effect.toggle(v, 'appear', {duration: 2, queue: id});
				slide = true;
			}
		}.bind(this));
		
		}
	}
}
