var slider = new Class({
	initialize: function (wrapper, items, options) {
		this.setOptions({
			layout: 'vertical',
			itemstyle: 'height',
			sizeSmall: 100,
			sizeNormal: 150,
			sizeFull: 200,
			transition: Fx.Transitions.Expo.easeOut
		},
		options);
		this.wrapper = $(wrapper);
		this.items = $$(items);
		this.fx = new Fx.Elements(this.items, {
			wait: false,
			duration: 600,
			transition: this.options.transition
		});
		if (this.options.layout != 'vertical') this.options.itemstyle = 'width';
		this.options.sizeSmall = Math.round(this.options.sizeNormal - ((this.options.sizeFull - this.options.sizeNormal) / (this.items.length - 1)));
		this.items.each(function (item, i) {
			item.addEvent('mouseenter', this.itemFx.bind(this, [item, i]))
		},
		this);
		this.wrapper.addEvent('mouseleave', this.wrapperFx.bind(this))
	},
	wrapperFx: function () {
		var o = {};
		this.items.each(function (item, i) {
			o[i] = this.itemStyle(item.getStyle(this.options.itemstyle).toInt(), this.options.sizeNormal);
		},
		this);
		this.fx.start(o)
	},
	itemFx: function (item, i) {
		var o = {};
		o[i] = this.itemStyle(item.getStyle(this.options.itemstyle).toInt(), this.options.sizeFull);
		this.items.each(function (other, j) {
			if (i != j) {
				var s = other.getStyle(this.options.itemstyle).toInt();
				if (s != this.options.sizeSmall) o[j] = this.itemStyle(s, this.options.sizeSmall);
			}
		},
		this);
		this.fx.start(o)
	},
	itemStyle: function (startVal, endVal) {
		if (this.options.layout == 'vertical') {
			return {
				height: [startVal, endVal]
			}
		} else {
			return {
				width: [startVal, endVal]
			}
		}
	}
});
slider.implement(new Options);