var Ticker = new Class({

    Implements: [Options],

    options: {
        container: $(document.body),
        duration: 7000,
		pauseOnOver: true
    },

    initialize: function(options) {
        this.setOptions(options);

        this.coords = this.options.container.getCoordinates();

		this.element = new Element('div').inject(this.options.container, 'after');
		this.element.setStyles({
			position: 'absolute',
			overflow: 'hidden',
			left: this.options.container.getStyle('left'),
			top: this.options.container.getStyle('top'),
			width: this.coords.width,
			height: this.coords.height
		});

		var self = this;

		this.ticker = new Element('div').inject(this.element);
		this.ticker.setStyles({
			width: this.coords.width * 2 + 2,
			height: this.coords.height
		});

		this.ticker.set('tween', {
			duration: this.options.duration,
			transition: 'linear',
			property: 'margin-left',
			onComplete: function(){
				this.start(0, -self.coords.width);
			}
		});
		this.ticker.get('tween').start(0, -self.coords.width).pause();

		this.options.container.setStyles({
			position: 'relative',
			left: 0,
			top: 0,
			'float': 'left'
		}).inject(this.ticker);
		this.options.container.clone().inject(this.ticker);

		if(this.options.pauseOnOver){
			this.element.addEvents({
				'mouseenter': this.stop.bind(this),
				'mouseleave': this.start.bind(this)
			})
		}
    },

    start: function() {
        this.ticker.get('tween').resume();
    },

	stop: function(){
		this.ticker.get('tween').pause();
	}
});
