function SetupSliders()
{
	$$('div.slider').each(function(slider) {

		slider.setAttribute('current','0');
		var left=slider.down();

		var center=left.next();
		var items=center.down();
		//I need at least three items for this to work.
		switch(items.children.length)
		{
			case 0:
				return;
			case 1:
				var rep=items.children[0].clone(true);
				var rep2=items.children[0].clone(true);
				items.appendChild(rep);
				items.appendChild(rep2);
				slider.setAttribute('total',3);
				break;
			case 2:
				var rep1=items.children[0].clone(true);
				var rep2=items.children[1].clone(true);
				items.appendChild(rep1);
				items.appendChild(rep2);
				slider.setAttribute('total',4);
				break;
		}
		
		left.onclick=function() {
			if(left.inprogress)
				return ;
			left.inprogress=1;

			var currentPos=parseInt(slider.getAttribute('current'));
			var total=parseInt(slider.getAttribute('total'));
			if(currentPos>0)
			{
				currentPos--;
				var center=left.next();
				var child=center.down();
				new Effect.Move(child,{x:-373*currentPos, y:0, mode:'absolute', afterFinish: function() {
					var childrenlength=child.children.length;
					var clone=child.children[0].clone(true);
					child.insertBefore(clone,child.children[1]);
					currentPos++;

					new Effect.Move(child,{x:-373*currentPos, y:0, mode:'absolute',duration:0.0,
						afterFinish: function () {
							var lastchild=child.children[childrenlength-1].remove();
							child.insertBefore(lastchild,child.children[0]);
							child.children[1].remove();
						
						}});
					slider.setAttribute('current',currentPos);
					left.inprogress=0;

					}
					});

			}
		}
		left.inprogress=0;

		var right=center.next();
		right.onclick=function() {
			if(right.inprogress)
				return;
			right.inprogress=1;
			var currentPos=parseInt(slider.getAttribute('current'));
			var total=parseInt(slider.getAttribute('total'));
			if(currentPos+1<total)
			{
				currentPos++;
				var center=right.previous();
				var child=center.down();
				new Effect.Move(child,{x:-373*currentPos, y:0, mode:'absolute', afterFinish: function() {
					var childrenlength=child.children.length;
					var clone=child.children[2].clone(true);
					child.insertBefore(clone,child.children[2]);
					currentPos--;

					new Effect.Move(child,{x:-373*currentPos, y:0, mode:'absolute',duration:0.0,
						afterFinish: function () {
							var firstchild=child.children[0].remove();
							child.children[2].remove();
							child.appendChild(firstchild);
						
						}});
					slider.setAttribute('current',currentPos);
					right.inprogress=0;
					
					}	});
							
				
			}
		}
		right.inprogress=0;
		var currentPos=parseInt(slider.getAttribute('current'));
		var total=parseInt(slider.getAttribute('total'));
		if(currentPos+1<total)
		{
			currentPos++;
			var center=right.previous();
			var child=center.down();
			new Effect.Move(child,{x:-373*currentPos, y:0, mode:'absolute', duration:0.0 });
			slider.setAttribute('current',currentPos);
		}
	

	});
	
}

