// UserScroller

scrollTimer = 0;
function layerScroll(layer,richtung,pixel,end) {
		
	if(richtung == "stop") {
		clearTimeout(scrollTimer);
	}
	
	else {		
				
		speed = 5;
		layer_para = layer;	
		pixel_para = pixel;	
		L = layer_data(layer_para);				
		var_end = end;		
		
		if(richtung == "up") {
			if (clip_values(L,'t') > 0) { 	
				clip_by(L,-pixel,0,-pixel,0);
				move(layer,0,pixel,0);
				scrollTimer=setTimeout("layerScroll(layer_para,'up',pixel_para,var_end)",speed);		
			}
		}
		
		else if(richtung == "down") {
			if (clip_values(L,'t') < end) { 									
				clip_by(L,pixel,0,pixel,0);
				move(layer,0,-pixel,0);

				scrollTimer=setTimeout("layerScroll(layer_para,'down',pixel_para,var_end)",speed);		
			}
		}
		else if(richtung == "left") {												
			if (layer_values(layer_para,'l')>end) { 								
				clip_by(L,0,pixel,0,pixel);				
				move(layer,-pixel,0,0);								
				scrollTimer=setTimeout("layerScroll(layer_para,'left',pixel_para,var_end)",speed);		
			}
		}
		else if(richtung == "right") {					
			if (layer_values(layer_para,'l')<end) { 	
				
				clip_by(L,0,-pixel,0,-pixel);
				move(layer,pixel,0,0);
				scrollTimer=setTimeout("layerScroll(layer_para,'right',pixel_para,var_end)",speed);		
			}
		}							
	}
}

