/* NAMESPACE */

	if (typeof JS == 'undefined') {
		var JS = {};
	}


/* CSS FIX */

	JS.CssFix = function(parent) {};
	

/* SCRIPT */

	JS.Fader = new Class({
		initialize: function(selector, interval, duration) {
			this.elements = $$(selector);
			if (!this.elements.length) {
				return;
			}
			this.interval = interval * 1000;
			this.duration = duration * 1000;
			this.effects = [];
			this.index = 0;
			this.elements.each(function(element, i) {
				element.get('tween').setOptions({duration: this.duration});
				if (i != 0) {
					element.setStyle('opacity', 0);
				}
			}, this);
			this.timer = this.rotate.periodical(this.interval, this);
		},
		rotate: function() {
			var index = (this.index == this.elements.length - 1) ? 0 : this.index + 1;
			
			this.elements[index].setStyle('z-index', 1);
			this.elements[this.index].setStyle('z-index', 0);
				
			this.elements[index].fade(1);
			var delay = function(element) {
				element.fade(0);
			}
			delay.delay(this.duration, this, this.elements[this.index]);
			
			this.index = index;	
		}
	});
	
	JS.Ticker = new Class({
		initialize: function(selector, interval, duration) {
			this.elements = $$(selector);
			if (this.elements.length < 2) {
				return;
			}	
			this.interval = interval * 1000;
			this.duration = duration * 1000;
			this.effects = [];
			this.index = 0;
			this.elements.each(function(element, i) {
				if (i != 0) {
					element.setStyle('left', '526px');
				}
			}, this);
			this.timer = this.rotate.periodical(this.interval, this);
		},
		rotate: function() {
			var index = (this.index == this.elements.length - 1) ? 0 : this.index + 1;
							
			this.elements[this.index]
				.set('tween', {duration: this.duration})
				.tween('left', '-526px');
			this.elements[index]
				.setStyle('left', '526px')
				.set('tween', {duration: this.duration})
				.tween('left', '0px');
			
			this.index = index;	
		}
	});
