﻿LM.Scroll = new Class({

	initialize: function(divID, elements, step, elementWidth) {
		//	initialize all the variables
		this.step = step;
		this.elements = elements;
		this.index = 0;
		this.scroller = $(divID)
		this.left = 0;
		this.top = 0;
		this.elementWidth = elementWidth;


		this.transitionOptions = {
			duration: '1500',
			transition: Fx.Transitions.Quad.easeInOut
			//fps: 60
		};

	},
	scrollRight: function(e, trackPath) {
		if ($chk(e)) e.stop();
		if ((this.index + 1) * this.step < this.elements.length) {
			this.left += -this.elementWidth * this.step;
			this.scroller.set('tween', this.transitionOptions);
			this.scroller.tween('left', this.left);
			this.index++;
			this.trackPath(trackPath);
		}
	},
	scrollLeft: function(e, trackPath) {
		if ($chk(e)) e.stop();
		if (this.index != 0) {
			this.left += this.elementWidth * this.step;
			this.scroller.set('tween', this.transitionOptions);
			this.scroller.tween('left', this.left);
			this.index--;
			this.trackPath(trackPath);
		}
	},
	scrollUp: function(e, trackPath) {
		if ($chk(e)) e.stop();
		if (this.index != 0) {
			this.top += this.elementWidth * this.step;
			this.scroller.set('tween', this.transitionOptions);
			this.scroller.tween('top', this.top);
			this.index--;
			this.trackPath(trackPath);
		}
	},
	scrollDown: function(e, trackPath) {
		if ($chk(e)) e.stop();
		if ((this.index + 1) * this.step < this.elements.length) {
			this.top += -this.elementWidth * this.step;
			this.scroller.set('tween', this.transitionOptions);
			this.scroller.tween('top', this.top);
			this.index++;
			this.trackPath(trackPath);
		}
	},
	resetX: function() {
		this.scroller.tween('left', 0);
	},
	resetY: function() {
		this.scroller.tween('top', 0);
	},
	trackPath: function(path) {
		if ($chk(path))
			pageTracker._trackPageview(path);
	}
});
