Slide = new Class({
	direction: 'left',
	stepSize: 50,
	autoPlay: true,
	length: 400,
	position: 0,
	initialize: function(config) {
		$extend(this, config);
		this.el = $(this.el);
		this.width = this.el.getStyle('width').toInt();
		this.el.addEvent('mouseover', function() {this.pause();}.bind(this));
		this.el.addEvent('mouseout', function() {this.resume();}.bind(this));

		if (this.autoPlay && this.width >= this.length) {
			this._walk = this.walk.periodical(2000, this);
		}
	},
	pause: function() {
		$clear(this._walk);
	},
	resume: function() {
		this._walk = this.walk.periodical(2000, this);
	},
	play: function(direction) {
		slide.pause();
		this.direction = direction;
		if (direction == 'right') {
			if (this.position == 0)	{
				return;
			} else if ((this.position - this.stepSize) <= 0) {
				this.el.tween('left', [-this.position, 0]);
				this.position = 0;
				this.direction = 'left';
			} else {
				this.el.tween('left', [-this.position, -this.position + this.stepSize]);
				this.position = this.position - this.stepSize;
			}
		} else {
			if (this.position == this.width) {
				return;
			} else if ((this.position + this.length + this.stepSize) >= this.width) {
				this.el.tween('left', [-this.position, this.length - this.width]);
				this.position = this.width - this.length;
				this.direction = 'right';
			} else {
				this.el.tween('left', [-this.position, -(this.position + this.stepSize)]);
				this.position = this.position + this.stepSize;
			}
		}
		slide.resume();

	},
	walk: function() {
		if (this.direction == 'right') {
			if ((this.position - this.stepSize) <= 0) {
				this.el.tween('left', [-this.position, 0]);
				this.position = 0;
				this.direction = 'left';
			} else {
				this.el.tween('left', [-this.position, -this.position + this.stepSize]);
				this.position = this.position - this.stepSize;
			}
		} else {
			if ((this.position + this.length + this.stepSize) >= this.width) {
				this.el.tween('left', [-this.position, this.length - this.width]);
				this.position = this.width - this.length;
				this.direction = 'right';
			} else {
				this.el.tween('left', [-this.position, -(this.position + this.stepSize)]);
				this.position = this.position + this.stepSize;
			}
		}
	}
});