<!--

var LogoPicker = new Class({
	options: {
		imagePath: "./images/content/sponsor-logos/",
		stages: [],
		images: []
	},
	initialize: function(options) {
		this.setOptions(options);
		this.imagePath = options.imagePath;
		this.stages = $$(options.stages);
		this.images = new Array();
		this.currentLogoIndex = this.stages.length;
		this.inMotion = false;
		options.images.each(function(item) {
			var el = new Asset.image(this.imagePath + item.source);
			if (item.link != null) {
				el = new Element("a", {"href": item.link, "target": "_blank"}).adopt(el);
			}
			this.images.push(el);
		}, this);
		(function() {this.updateLogos()}).periodical(LogoPicker.LogoDispTime, this);
	},
	updateLogos: function() {
		if (!this.inMotion) {
			this.inMotion = true;
			this.stages.each(function(item) {
				var newLogo = this.images[this.currentLogoIndex++];
				if (this.currentLogoIndex >= this.images.length) {
					this.currentLogoIndex = 0;
				}
				item.logoAnim = new Fx.Style(newLogo, "top", {duration: LogoPicker.LogoScrollTime, transition: Fx.Transitions.Cubic.easeOut});
				item.logoAnim.set(LogoPicker.LogoY);
				item.logoAnim.addEvent("onStart", function() {
					item.adopt(newLogo);
				});
				item.logoAnim.addEvent("onComplete", function() {
					item.getFirst().remove();
					this.inMotion = false;
				}.bind(this));
				item.logoAnim.start(LogoPicker.LogoY, 0);
			}, this);
		}
	}
});
LogoPicker.implement(new Events, new Options);
LogoPicker.LogoDispTime = 6000;
LogoPicker.LogoScrollTime = 1000;
LogoPicker.LogoY = 112;