var LogoSlider = new Activa.Class({
	container: null,
	slider: null,
	clone: null,
	direction: null,
	slider_left: null,
	slider_width: null,
	clone_left: null,
	clone_width: null,
	options: {
		fps:30,
		speed:1,
		direction:'left'
	}, 
	
	init: function init(container, slider, clone_name, options) {
		this.container = container;
		this.slider = slider;
		this.setOptions(options);
		
		this.clone = this.slider.cloneNode(true);
		this.clone.id = clone_name;
		this.container.insertBefore(this.clone, this.slider);
		switch ( this.options.direction ) {
			case 'left':
				this.clone.style.left = this.numericOnly(this.slider.style.left) + this.numericOnly(this.slider.offsetWidth) + 'px';
				break;
			case 'right':
				this.clone.style.left = this.numericOnly(this.slider.style.left) - this.numericOnly(this.clone.offsetWidth) + 'px';
				break;
		}
		
		this.slider_left = this.numericOnly(this.slider.style.left);
		this.slider_width = this.numericOnly(this.slider.offsetWidth);
		
		this.clone_left = this.numericOnly(this.clone.style.left);
		this.clone_width = this.numericOnly(this.clone.offsetWidth);
		
		setInterval(this.move.bind(this), 1000 / this.options.fps);
	},
	numericOnly: function numericOnly(val) {
		if ( !isNaN(parseInt(val)) ) {
			return parseInt(val);
		}
		return 0;
	},
	setOptions: function setOptions(options) {
		options = options || {};
		for ( var k in this.options ) {
			this.options[k] = (k in options) ? options[k] : this.options[k];
		}
	},
	move: function move() {
		switch ( this.options.direction ) {
			case 'left':
				this.slider_left -= this.options.speed;
				this.clone_left -= this.options.speed;
				
				this.slider.style.left = this.slider_left + 'px';
				this.clone.style.left = this.clone_left + 'px';
				
				if ( Math.abs(this.slider_left) >= this.slider_width ) {
					this.slider.style.left = this.clone_left + this.clone_width + 'px';
					this.slider_left = this.numericOnly(this.slider.style.left); 
				}
		
				if ( Math.abs(this.clone_left) >= this.clone_width ) {
					this.clone.style.left = this.slider_left + this.slider_width + 'px';
					this.clone_left = this.numericOnly(this.clone.style.left);
				}
				break;
			case 'right':
				this.slider_left += this.options.speed;
				this.clone_left += this.options.speed;
				
				this.slider.style.left = this.slider_left + 'px';
				this.clone.style.left = this.clone_left + 'px';
				
				if ( Math.abs(this.slider_left) >= this.slider_width ) {
					this.slider.style.left = this.clone_left - this.clone_width + 'px';
					this.slider_left = this.numericOnly(this.slider.style.left); 
				}
		
				if ( Math.abs(this.clone_left) >= this.clone_width ) {
					this.clone.style.left = this.slider_left - this.slider_width + 'px';
					this.clone_left = this.numericOnly(this.clone.style.left);
				}
				break;
		}
	}
});