	$(document).ready(function() {
		
			//Speed of the slideshow
			var speed = 5000;
			
			//You have to specify width and height in #slider CSS properties
			//After that, the following script will set the width and height accordingly
			$('#torneoImageMask, #torneoGallery li').width($('#torneoImageSlider').width());	
			$('#torneoGallery').width($('#torneoImageSlider').width() * $('#torneoGallery li').length);
			$('#torneoImageMask, #torneoGallery li').height($('#torneoImageSlider').height());
			
			//Assign a timer, so it will run periodically
			var run = setInterval('newsscoller(0)', speed);	
			
			$('#torneoGallery li:first, #torneoTextGallery li:first').addClass('selected');
			
			//Next Slide by calling the function
			$('#torneoImageNextButton').click(function () {
				newsscoller(0);	
				return false;
			});	
			
			//Mouse over, pause it, on mouse out, resume the slider show
			$('#torneoImageSlider, #torneoImageNextButton').hover(
			
				function() {
					clearInterval(run);
				}, 
				function() {
					run = setInterval('newsscoller(0)', speed);	
				}
			); 	
			
		});
		
		
		function newsscoller(prev) {
		
			//Get the current selected item (with selected class), if none was found, get the first item
			var current_image = $('#torneoGallery li.selected, #torneoTextGallery li.selected').length ? $('#torneoGallery li.selected, #torneoTextGallery li.selected') : $('#torneoGallery li:first, #torneoTextGallery li:first');
		
			//if prev is set to 1 (previous item)
			if (prev) {
				
				//Get previous sibling
				var next_image = (current_image.prev().length) ? current_image.prev() : $('#torneoGallery li:last, #torneoTextGallery li:last');
			
			//if prev is set to 0 (next item)
			} else {
				
				//Get next sibling
				var next_image = (current_image.next().length) ? current_image.next() : $('#torneoGallery li:first, #torneoTextGallery li:first');
			}
		
			//clear the selected class
			$('#torneoGallery li, #torneoTextGallery li').removeClass('selected');
			
			//reassign the selected class to current items
			next_image.addClass('selected');
		
			//Scroll the items
			$('#torneoImageMask, #torneoTextMask').scrollTo(next_image, 1000);				
			
		}