
var curr_spotlight = 0;
var timer;

$(document).ready(function(){
	
	open_spotlight(0);
	
	$('.spotlight-butts').click(function(){ 
		
		curr_spotlight = $(this).attr('title');
		open_spotlight(curr_spotlight);
		clearInterval(timer);
		return false;
	});

	timer = setInterval("change_spotlight()", 7000);
});

function change_spotlight(){
	
	if (curr_spotlight == n_spotlights - 1){

		curr_spotlight = 0;
	
	} else {
		
		curr_spotlight++;
	}
	
	open_spotlight(curr_spotlight);
}

function open_spotlight(ref){
	
	$('.spotlight-butts').find('img').attr('src', '/images/ico_rating_off.png');

	html_content	= '<a href="/artists/detail/' + spotlights[ref]['artist_id'] + '">' + spotlights[ref]['name'] + '</a><br />'
					+ '<span class="spotlight-description">' + spotlights[ref]['spotlight'] + '</span>';

	$('#artist-spotlight').css('background', 'transparent url("/uploads/artists/large/' + spotlights[ref]['image_wide'] + '") repeat scroll 0 0');
	$('p#spotlight-title').html(html_content);
	$('span#spotlight-' + ref).find('img').attr('src', '/images/ico_rating_on.png');
}