var MooSlide = new Class({
	doSlide: function() {
		center = this.visible_slide;
		next = center.getNext();
		if(next == null) {
			next = this.slides[0];
		}
		// mooTools 1.2:
		//var cfx = new Fx.Morph(center);
		//var nfx = new Fx.Morph(next);
		//cfx.start({'left': this.width});
		//nfx.start({'left': 0});

		// mooTools 1.1:
		var cfx = new Fx.Style(center, 'left');
		var nfx = new Fx.Style(next, 'left');
		cfx.start(this.width);
		nfx.start(0);
		for(i = 0; i < this.slides.length; i++) {
			if(this.slides[i] == next || this.slides[i] == center) {
				continue;
			}
			this.slides[i].setStyle('left', -(this.width));
		}
			
		this.visible_slide = next;
	},
	
	initialize: function(slide_element, width) {
		this.mooslide = $(slide_element);
		this.width = width;
		this.slides = this.mooslide.getChildren();
		this.visible_slide = this.slides[0];
		
		this.slides.each(function(s) {
			$(s).setStyle('left', -width);
		});
		this.visible_slide.setStyle('left', 0);
	} 
});

window.addEvent('domready', function() {
	if($('mooslide') != null) {
		$('mooslide').setStyle('display', 'block');
		var ms = new MooSlide('mooslide', 222);
		ms.doSlide.periodical(2000, ms);
	}
});

