var t;
function rand ( n )
{
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

function move(velocity){

	position=elem.style.backgroundPosition.split(" ");
	right=parseInt(position[0].replace(/px/,""));
	right=right+velocity;
	right=right+"px";
	elem.style.backgroundPosition = right;
	t=setTimeout("move("+velocity+")",100);

}



function banner_load(img_name, max_velocity, max_time) {
//	alert(img_name+" "+max_velocity+" "+max_time);
 	elem=document.getElementById(img_name);
	elem.style.backgroundPosition=rand(1000)+"px";
	velocity=max_velocity/5;
	move(velocity);
//	changeStyle(max_velocity, max_time);

}


function changeStyle(max_velocity, max_time)  {	
	velocity=0;
	max_velocity=5; 
	max_time=5;
	clearTimeout(t);
	movetime=rand(max_time)+1;

	while (velocity==0) velocity=Math.floor(rand(max_velocity)-(max_velocity/2));


//	alert(movetime+" "+velocity);
	move(velocity);


	setTimeout("changeStyle("+max_velocity+","+max_time+")",movetime*1000);

//setTimeout("clearTimeout(t);",1000);

  }

