var x=0, running;
var speeds= new Array(25,50,75);
var speed=speeds[0];
var step=1;
var mode=1;	// 1=continuous forward, 2=continuous backward, 3=back and forth
var dist=2685;

function start(id) {
	if ( mode == 2 && step>0 ) step *= -1;
	else if ( mode == 1 ) step = Math.abs(step);
	window.clearInterval(running);
	running = setInterval("scroll('"+id+"')", speed);
}

function scroll(id) {
	x += step;
	document.getElementById(id).style.backgroundPosition=""+x+"px 0px";
	if ( mode == 3 && x <= -1*dist ) {
		step = Math.abs(step);
	}
	else if ( mode == 2 && x <= -1*dist ) {
		x=0;
	}
	else if ( x >= dist ) {
		if (mode==3) step *= -1;
		else x=0;
	}
}
