$(document).ready(function(){
	$("#adv_left_top").rotator({ms:5000});
	$("#adv_left_bott").rotator({ms:5000});
	$("#adv_right_top").rotator({ms:5000});
});

$(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
	$('#mask_evento, #evento li').width($('#wrap_evento_index').width());	
	$('#evento').width($('#wrap_evento_index').width() * $('#evento li').length);
	$('#mask_evento, #evento li, #mask_info, #info li').height($('#wrap_evento_index').height());
	
	//Assign a timer, so it will run periodically
	var run = setInterval('newsscoller(0)', speed);	
		
	//Mouse over, pause it, on mouse out, resume the slider show
	$('#wrap_evento_index').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 = $('#evento li.selected').length ? $('#evento li.selected') : $('#evento li:first');
	var current_excerpt = $('#info li.selected').length ? $('#info li.selected') : $('#info 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() : $('#evento li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#info li:last');
	
	//if prev is set to 0 (next item)
	} else {
		
		//Get next sibling
		var next_image = (current_image.next().length) ? current_image.next() : $('#evento li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#info li:first');
	}

	//clear the selected class
	$('#info li, #evento li').removeClass('selected');
	
	//reassign the selected class to current items
	next_image.addClass('selected');
	next_excerpt.addClass('selected');

	//Scroll the items
	$('#mask_evento').scrollTo(next_image, 800);		
	$('#mask_info').scrollTo(next_excerpt, 800);					
	
}
