var scrollAction = null;
var scrollSpeed = null;
var scrollTime = null;

function processScroll(){
	if(scrollAction == null){
		return;
	}
	
	var tbl = $('zoom_additionalimages')
	
	var min = -(tbl.getWidth() - 301 + 10);
	var max = 21;
	
	var delta = 2;
	if(scrollSpeed == 'fast'){
		delta = 5;
	}else if(scrollSpeed == 'veryfast'){
		delta = 63
	}
	
	if(scrollAction == 'prev'){
		delta = -delta;
	}
	
	var newLeft = parseInt(tbl.getStyle("left")) + delta
	
	if(newLeft > max){
		newLeft = max;
	}
	
	if(newLeft < min){
		newLeft = min
	}
	
	tbl.setStyle({left: newLeft + "px"})
	
	window.setTimeout('processScroll()', 50)
}
function startScroll(action, speed){
	scrollAction = action;
	scrollSpeed = speed;
	scrollTime = new Date();
	processScroll();
}
function stopScroll(check){
	if(check == true){
		var d = new Date();
		if((d.getTime() - scrollTime.getTime()) < 300){
			processScroll('veryfast');
		}
	}else{
		processScroll();
	}
	scrollAction = null;
}
