
var timer;
var curr_image				= 0;

$(document).ready(function(){

	$('#artist-tabs li a').click(function(){
		
		$('#artist-tabs li').removeClass('active');
		$(this).parent().addClass('active');
		$('div.tab-page').hide();
		$('#' + $(this).attr('rel')).show();
		$(this).blur();
		return false;
	});

	timer = setInterval("change_image()", 7000);

	// manual page breaking
	
	var n_bio_sets				= $('div.page').length;
	var curr_bio_set			= 0;
	
	if (n_bio_sets > 1){

		$('div.page').not(':first').hide();
	
		$('div.pages li').hide();
		for (i = 0; i < n_bio_sets ; i++){ $('div.pages li:eq(' + i + ')').show(); }

		$('div.pages a').click(function(){
			
			var rel = $(this).attr('rel');
			$('div.pages li').removeClass('active');
			$('div.page').hide();
			$('div.page:eq(' + rel + ')').show();
			$(this).parent().addClass('active');
			return false;
		});
	
	} else {
		
		$('div.pages').hide();
	}


	// tour dates pagination
	
	var n_tour_sets				= $('div.tour-pages li').length;
	var curr_tour_set			= 0;
	
	if (n_tour_sets > 1){
	
		$('div.tour-pages a').click(function(){
			
			var rel = $(this).attr('rel');
			$('div.tour-pages li').removeClass('active');
			$(this).parent().addClass('active');

			$('#tour .tour-cell').hide();
			$('#tour .page-' + rel).show();

			return false;
		});
	
	} else {
		
		$('div.tour-pages').hide();
	}


	// news pagination
	
	var n_news_sets				= $('div.news-pages li').length;
	var curr_news_set			= 0;
	
	if (n_news_sets > 1){
	
		$('div.news-pages a').click(function(){
			
			var rel = $(this).attr('rel');
			$('div.news-pages li').removeClass('active');
			$(this).parent().addClass('active');

			$('#news .tour-cell').hide();
			$('#news .page-' + rel).show();

			return false;
		});
	
	} else {
		
		$('div.news-pages').hide();
	}
});

function change_image(){
	
	if (curr_image == n_images - 1){

		curr_image = 0;

	} else {
		
		curr_image++;
	}

	$('#big-artist-box').css('background-image', 'url(/uploads/artists/large/' + artist_images[curr_image]['image_wide'] + ')');
}