var Rotator = new Class({

	/* initialize needed methods
	 ======================================================================= */
	initialize: function() {
		this.rotator = $('ar-intro-images');
		if(this.rotator) {
			this.counter 	= 1;
			this.slides 	= $$('#ar-intro-images .fItem');
			listItems 		= $$('#artists-room-list li');
			
			if(this.slides.length <= 1) return false;

			this.slides.each(function(slide, i) {
				slide.setStyle('opacity', i==0?1:0);
				slide.set('tween', {duration: 300, transition: Fx.Transitions.sineOut});
			});
			
			this.rotator.setStyle('visibility', 'visible');
			
			this.slides.each(function(el) {
				if($(el.getProperty('rel'))) {
					el.addEvents({
						mousemove: function() {
							listItems.each(function(el) {
								el.removeClass('active');
							});
							$(el.getProperty('rel')).addClass('active');
						},
						mouseout: function() {
							listItems.each(function(el) {
								el.removeClass('active');
							});
						}
					});
				}
			}); 

			this.start.periodical(6000, this);
		}
	},

	/* attach events and add the initially fired methods
	 ======================================================================= */
	start: function() {	
		if(this.counter == this.slides.length) this.counter = 0;
		this.counter++;
		
		this.slides.each(function(el) {
			el.tween('opacity', 0);
		});
		
		this.slides[this.counter-1].tween('opacity', [0, 1]);
	}
});
