
var scrbusy = 0;
var scrtimer = 0;
var cur = 1;
var scrolltime = 7000;


function start()
	{
	setTimeout("go()",scrolltime);
	}


function go()
	{
	rand = Math.ceil(Math.random()*max);
	
	if (cur != rand)
		{
		scr(rand);
		cur = rand;
		}
	else
		{
		go();
		}
	}

function scr(id)
	{
	end = document.images["opl"+id].offsetLeft-177;
	start = document.body.scrollLeft;
	if (scrbusy == 1)
		{
		clearTimeout(scrtimer);
		}
	scrmv(start,end);
	scrbusy = 1;
	}


function scrmv (start, end)
	{
	diff = end - start;
	
	adiff = Math.abs(diff);

	if (adiff > 200)
		speed = 25;
	else if (adiff > 100)
		speed = 20;
	else if (adiff > 50)
		speed = 10;
	else if (adiff > 20)
		speed = 5;
	else if (adiff > 10)
		speed = 2;	
	else if (adiff > 3)
		speed = 1;

	if (diff < 0)
		{
		newx = start-speed;
		scrollTo(newx,0);
		if (bodydiv.filters[0])
			{
			bodydiv.filters[0].strength=Math.round(speed/2);
			bodydiv.filters[0].direction=-90;
			}
		scrtimer = setTimeout("scrmv("+newx+","+end+")",10);
		}	
	else if (diff > 0)
		{
		newx = start+speed;
		scrollTo(newx,0);
		if (bodydiv.filters[0])
			{
			bodydiv.filters[0].strength=Math.round(speed/2);
			bodydiv.filters[0].direction=90;
			}
		scrtimer = setTimeout("scrmv("+newx+","+end+")",10);
		}
	else
		{
		if (bodydiv.filters[0])
			bodydiv.filters[0].strength=0;
		scrbusy = 0;
		setTimeout("go()",scrolltime);
		}
	}
