function scrollleftfunc_click() {
	currentx = parseInt($("scroller").style.left);
	if((currentx+scrollerwidth)<count){
		var quickmove = 0-(scrollerwidth+currentx);
	} else {
		var quickmove = 0-count;
	}

	if((currentx+scrollerwidth)>0) {

		stopscroller();
		new Effect.Move('scroller', { 
		  x: quickmove,
		  y: 0.0, 
		  mode: "relative", duration: fastspeed,
		  queue: {position: 'start', scope: 'scrollerQ'},
		  afterFinish: function(){
		  	restartscroller();
		  	}
		});
  } else {
  	direction='right';
  	stopscroller();
  	restartscroller();
  }
}



function scrollrightfunc_click() {
	currentx = parseInt($("scroller").style.left);
	
	if(currentx<0 && (currentx+count)>0){
		var quickmove = 0-currentx;

	} else {
		var quickmove = count;
	}

	if(currentx<0) {

		stopscroller();
		new Effect.Move('scroller', { 
		  x: quickmove,
		  y: 0.0, 
		  mode: "relative", duration: fastspeed,
		  queue: {position: 'start', scope: 'scrollerQ', limit: 3 },
		  afterFinish: function(){
		  	restartscroller();
		  	}
		});
  } else {
  	direction='left';
  	stopscroller();
  	restartscroller();
  }
}


function startscroller() {
	currentx = parseInt($("scroller").style.left);
  
	if(direction=='left') {

		new Effect.Move('scroller', { 
		  x: 0-(scrollerwidth+currentx),
		  y: 0.0, 
		  mode: "relative", duration: (speed * ((scrollerwidth+currentx)/scrollerwidth)),
		  queue: {position: 'end', scope: 'scrollerQ'},
		  afterFinish: function(){
		  	direction = 'right';
		  	startscroller();
		  	}
		});

	}	else {
		var movexTo = scrollerwidth;
		if(currentx>(0-scrollerwidth)) {
			movexTo = 0-currentx ;
		}

		new Effect.Move('scroller', { 
		  x: movexTo,
		  y: 0.0, 
		  mode: "relative", duration: (speed * (movexTo/scrollerwidth)),
		  queue: {position: 'end', scope: 'scrollerQ'},
		  afterFinish: function(){
		  	direction = 'left';
		  	startscroller();
		  	}
		});
	}			
}


function stopscroller() {
	currentx = parseInt($("scroller").style.left);
	var queue = Effect.Queues.get('scrollerQ');
	queue.each(function(effect) { effect.cancel(); });
	scrollerstopped = true;
}

function restartscroller() {
	if(scrollerstopped) {
			var queue = Effect.Queues.get('scrollerQ');
			queue.each(function(effect) { effect.cancel(); });
			startscroller();
			scrollerstopped=false;
	}					
}