var counter = 1;
var timer =  null;
var started = false;

var active_slideshow = true;
var active_tab = 1;

var tab_delai = 13000;
var start_fade_delai = 1500;
var fade_delai = 750;
var fade_stop_delai = 400;



function start_slideshow() {
	if (active_slideshow) {
		if (started == false) {
			$('#scrollable1').get(0).style.visibility = 'visible';
			$('#scrollable2').get(0).style.visibility = 'visible';
			$('#scrollable3').get(0).style.visibility = 'visible';
			$('#scrollable4').get(0).style.visibility = 'visible';
			//$('#main_artist_container').fadeOut(0).fadeIn(start_fade_delai);
			$('#promo-txt').fadeOut(0).fadeIn(start_fade_delai);
			$('#artist_fader').fadeIn(0).fadeOut(start_fade_delai);
			
			showsTabbedPanels.showPanel(0);
			loadDisplayArtistInfos(1);
			
			for (i = 1; i <= 4; i++) {
				if (i == 1) {
					$('#scrollable' + i).get(0).className = 'scrollable' + i + ' visible';
				} else {
					$('#scrollable' + i).get(0).className = 'scrollable' + i + ' invisible';
				}
			}
			
			$('#fader').fadeOut(start_fade_delai);
			setTimeout("start_slideshow()", tab_delai);
			started = true;
			counter = 1;
			return;
		}
		
		$('#artist_fader').fadeIn(fade_delai).delay(fade_stop_delai).fadeOut(fade_delai).delay(tab_delai);
		//$('#main_artist_container').fadeOut(fade_delai).delay(fade_stop_delai).fadeIn(fade_delai).delay(tab_delai);
		$('#promo-txt').fadeOut(fade_delai).delay(fade_stop_delai).fadeIn(fade_delai).delay(tab_delai);
		
		$('#fader').fadeIn(fade_delai, function() {
			
			for (i = 1; i <= 4; i++) {
				if (i == counter) {
					$('#scrollable' + i).get(0).className = 'scrollable' + i + ' visible';
				} else {
					$('#scrollable' + i).get(0).className = 'scrollable' + i + ' invisible';
				}
			}
			
			showsTabbedPanels.showPanel(counter - 1);
			loadDisplayArtistInfos(counter);
			
			var api = $(".scrollable" + counter).data("scrollable");
			api.seekTo(0, 0);
			
		}).delay(fade_stop_delai).fadeOut(fade_delai, function() {
			if (active_slideshow == true) { start_slideshow(); }
		}).delay(tab_delai);
		
		counter++;
		if (counter == 5) { counter = 1; }
	}
}

function stop_slideshow(id) {
	//id++;
	
	for (i = 1; i <= 4; i++) {
		if (i == active_tab) {
			$('#scrollable' + i).get(0).className = 'scrollable' + i + ' visible';
		} else {
			$('#scrollable' + i).get(0).className = 'scrollable' + i + ' invisible';
		}
	}
	
	var api = $(".scrollable" + active_tab).data("scrollable");
	api.seekTo(0, 0);
	
	active_slideshow = false
}
