function rollbar() {
	this.elms = new Array();
	this.leftIndex			= 0;
	this.rightIndex			= 3;
	this.elmsNumber			= 10;
	this.elmWidth			= 150;
	this.pixels2move		= 15;
	this.animationInterval	= 1;
	this.leftPos			= 0;
	this.opacity			= 100;
	this.opacityStep		= 10.5;
	this.animatorCounter	= 0;
	this.rollbarId			= '';
	this.counterId			= '';
	this.animator;
	this.IE = false;
	this.Mozilla = false;
	this.init = function(id, counterId) {
		if(document.all && navigator.appName.indexOf("Opera") == -1) this.IE = true;
		this.Mozilla = navigator.appName.indexOf("Netscape") != -1;
		this.rollbarId = id;
		this.counterId = counterId;
		this.elms = document.getElementById('rollbarinner').getElementsByTagName('div');
		divs = document.getElementById(id).getElementsByTagName('div');
		for(i in divs) {
			if(divs[i].className == 'left') {
				navi = divs[i].getElementsByTagName('a');
				navi[0].onclick = function() { rollbar.scroll('R'); return false; };
				navi[0].onfocus = function() { this.blur(); return false; };
			} else if (divs[i].className == 'right') {
				navi = divs[i].getElementsByTagName('a');
				navi[0].onclick = function() { rollbar.scroll('L'); return false; };
				navi[0].onfocus = function() { this.blur(); return false; };
			}
		}
		this.deactivateButton('left');
		this.activateButton('right');
	}
	
	this.activateButton = function(buttonName) {
		divs = document.getElementById(this.rollbarId).getElementsByTagName('div');
		for(i in divs) {
			if(divs[i].className == buttonName) {
				navi = divs[i].getElementsByTagName('a');
				navi[0].style.backgroundPosition = '0 0';
				navi[0].onmousedown	= function() { this.style.backgroundPosition = '0 -48px'; }
				navi[0].onmouseup	= function() { this.style.backgroundPosition = '0 -24px'; }
				navi[0].onmouseover	= function() { this.style.backgroundPosition = '0 -24px'; }
				navi[0].onmouseout	= function() { this.style.backgroundPosition = '0 0'; }
			}
		}
	}
	
	this.deactivateButton = function(buttonName) {
		divs = document.getElementById(this.rollbarId).getElementsByTagName('div');
		for(i in divs) {
			if(divs[i].className == buttonName) {
				navi = divs[i].getElementsByTagName('a');
				navi[0].style.backgroundPosition = '0 -72px';
				navi[0].onmousedown	= function() { this.style.backgroundPosition = '0 -72px'; }
				navi[0].onmouseup	= function() { this.style.backgroundPosition = '0 -72px'; }
				navi[0].onmouseover	= function() { this.style.backgroundPosition = '0 -72px'; }
				navi[0].onmouseout	= function() { this.style.backgroundPosition = '0 -72px'; }
			}
		}
	}
	
	this.scroll = function(direction) {
		if(this.animator || (direction == 'R' && this.leftIndex == 0) || (direction == 'L' && this.rightIndex == (this.elmsNumber - 1))) {
			return;
		}
		this.leftPos = direction == 'R' ? -(this.elmWidth) : 0;
		this.opacity	= 0;
		if(direction == 'R') {
			this.leftIndex--;
			if(this.leftIndex == 0) this.deactivateButton('left');
			if(this.rightIndex == this.elmsNumber - 1) this.activateButton('right');
		} else {
			if(this.leftIndex == 0) this.activateButton('left');
			this.rightIndex++;
			if(this.rightIndex == this.elmsNumber - 1) this.deactivateButton('right');
		}
		this.animator = setInterval('rollbar.doScroll(' + this.leftIndex + ', ' + this.rightIndex + ', \'' + direction + '\')', this.animationInterval);
		if(direction == 'R') {
			this.rightIndex--;
		} else {
			this.leftIndex++;
		}
	}
		
	this.doScroll = function(leftIndex, rightIndex, direction) {
		this.elms[leftIndex].style.marginLeft = this.leftPos + 'px';
		if(direction == 'R') {
			this.elms[leftIndex].outerHTML = this.elms[leftIndex].outerHTML;
		}
		if(this.opacity > 100) { this.opacity = 100; }
		if(this.IE) {
			this.elms[leftIndex].filters.alpha.opacity = (direction == 'L' ? 100 - this.opacity : this.opacity);
			this.elms[rightIndex].filters.alpha.opacity = (direction == 'L' ? this.opacity : 100 - this.opacity);
		} else if(this.Mozilla) {
			//this.elms[leftIndex].style.MozOpacity = (direction == 'L' ? 100 - this.opacity : this.opacity) / 100;
			//this.elms[rightIndex].style.MozOpacity = (direction == 'L' ? this.opacity : 100 - this.opacity) / 100;
		}
		if(this.animatorCounter >= this.elmWidth / this.pixels2move) {
			this.animatorCounter = 0;
			clearInterval(this.animator);
			this.animator = null;
			return;
		}
		this.opacity += this.opacityStep;
		this.animatorCounter++;
		this.leftPos += (direction == 'L' ? -(this.pixels2move) : this.pixels2move);
	}
}
var rollbar = new rollbar();rollbar.init('mpsmall', 'mpscount');

