var defaultSpeed=2;
var maxSpeed=50;

var totalWidth=0;
var displayWidth=0;
var displayHeight=0;
var speed=defaultSpeed;


function initScroll(outer_box,inner_box,scroll_box,content_box){

	imgBox=document.getElementById(scroll_box);

	displayWidth=parseInt(document.getElementById(inner_box).style.width);
	displayHeight=document.getElementById(content_box).offsetHeight;
	totalWidth=document.getElementById(content_box).offsetWidth;
	imgHolderWidth=displayWidth;
	document.getElementById(outer_box).style.width=imgHolderWidth+"px";
	document.getElementById(inner_box).style.width=imgHolderWidth+"px";
	imgBox.style.width=totalWidth+"px";

	imgHolderHeight=displayHeight;
	document.getElementById(inner_box).style.height=imgHolderHeight+"px"; 
	document.getElementById(inner_box).style.clip="rect(0,"+(imgHolderWidth+"px")+","+(imgHolderHeight+"px")+",0)";
	
}

leftTimer="";
function scroll(n){

	clearTimeout(leftTimer);
	imgBoxPos=parseInt(imgBox.style.left);
	if(n==1){
		imgBoxPos-=speed;
	}
	else{
		imgBoxPos+=speed;
	}

	imgBox.style.left=imgBoxPos+"px";
	leftTimer=setTimeout("scroll("+n+")",50);

	if(n==1&&imgBoxPos< -(totalWidth-imgHolderWidth)){
		imgBox.style.left=-(totalWidth-imgHolderWidth)+"px";
		clearTimeout(leftTimer);
	}

	if(n==0&&imgBoxPos> 0-speed){
		imgBox.style.left=0;
		clearTimeout(leftTimer);
	}

}

function fast(){
	speed=maxSpeed;
}

function slow(){
	speed=defaultSpeed;
}

function pause(){
	clearTimeout(leftTimer);
}




