How do I create a basic jquery loop?
===

I'm trying to create a simple loop that will go round and round and can be stopped and started.

I tried calling itself such as this

    var theloop = (function(){
					
				var theloop = (function(){
					
				$('#goldspot-2012 ul#goldspot-2012-list li').eq(currentItem).removeClass('current').fadeOut(500);
				$('#goldspot-2012 ul#goldspot-2012-list li').eq(currentItem+1).addClass('current').fadeIn(500);
				$('#gs-controls ul li').eq(currentItem).removeClass('current');				
				$('#gs-controls ul li').eq(currentItem+1).addClass('current');			
				
				if (currentItem == items -1){
					currentItem = 0;
					theloop();
				}
					
				else {
					currentItem++;	
					theloop();
				}
				
				
				
			});

which just errors out as I imagine its stuck in some endless loop

I've also tried

    var theloop = setInterval(function(){
					
				$('#goldspot-2012 ul#goldspot-2012-list li').eq(currentItem).removeClass('current').fadeOut(500);
				$('#gs-controls ul li').eq(currentItem).removeClass('current');							
				
				if (currentItem == items -1){
					currentItem = 0;
				}
					
				else {
					currentItem++;	
				}
				$('#goldspot-2012 ul#goldspot-2012-list li').eq(currentItem).addClass('current').fadeIn(500);
				$('#gs-controls ul li').eq(currentItem).addClass('current');
				
			}, 5000);

but this can't be stopped and started easily.

Can anyone just show me a basic loops that will keep going until you stop it or is one of the two above workable with a little tinkering?

Thanks