/**
 * Roller
 */

jvRoller = function(count, interval, callback) {
	this.timer = null;
	this.count = count;
	this.index = 0;
	this.interval = interval;
	this.callback = callback;
};

jvRoller.prototype = {
	
	start: function() {
		var self = this;
		
		this.stop();
		this.timer = setInterval(function() {
			self.index++;
			if (self.index > self.count) {
				self.index = 1;
			}
			
			if (self.callback) {
				self.callback(self);
			}
		}, this.interval);
	},
	stop: function() {
		if (this.timer) {
			clearInterval(this.timer);
			this.timer = null;
		}
	},
	mouseOver: function() {
		this.stop();
	},
	mouseOut: function() {
		this.start();
	},
	current: function(idx) {
		if (idx) {
			this.index = idx;
		}
		return this.index;
	},
	nothing: function() {}
}

