var intervalID;
var slideShowTime = 7000 // each 1000 = 1 second

$(document).ready(function() {
	intervalID = setInterval(function() {
		//$currentFrame = $('.currentFrame').html();
		featuredSlideshowNextFrame();
    }, slideShowTime);
	
});

function featuredSlideshowNextFrame() { //* Current Frame
	// Get the current frame
	$('.featured-slider-slot').removeClass('featured-slider-slot-active');
	if (parseFloat($('.currentFrame').html()) < 4) { // If the current frame is less than 4, add one; else, reset
		currentFrame = parseFloat($('.currentFrame').html()) + 1;
		$('#featured-panel-' + (currentFrame - 1)).hide();
		$('#featured-panel-' + currentFrame).show();
		$('#featured-slider-slot-' + (currentFrame - 1)).removeClass('featured-slider-slot-active');
		$('#featured-slider-slot-' + currentFrame).addClass('featured-slider-slot-active');
		$('#featured-slider-slot-arrow-' + (currentFrame - 1)).hide();
		$('#featured-slider-slot-arrow-' + (currentFrame)).show();
	} else {
		currentFrame = 1;
		$('#featured-panel-4').hide();
		$('#featured-panel-' + currentFrame).show();
		$('#featured-slider-slot-4').removeClass('featured-slider-slot-active');
		$('#featured-slider-slot-1').addClass('featured-slider-slot-active');
		$('#featured-slider-slot-arrow-4').hide();
		$('#featured-slider-slot-arrow-1').show();
	}
	$('.currentFrame').html(currentFrame);
}

function stopFeaturedSlideshow(n) { // n = the number in the slider that is hovered over
	//alert(n);
	currentFrame = parseFloat($('.currentFrame').html());
	if (n) {
		$('#featured-panel-' + currentFrame).hide();
		$('#featured-panel-' + n).show();
		$('.featured-slider-slot').removeClass('featured-slider-slot-active');
		$('#featured-slider-slot-' + n).addClass('featured-slider-slot-active');
		$('.featured-slider-slot-arrow').hide();
		$('#featured-slider-slot-arrow-' + (n)).show();
	}
	clearInterval(intervalID);	// Stop the slideshow
	$('.currentFrame').html(n);
	$('.slideshowOnOff').html('off');
}

function startFeaturedSlideshow() {
	if ($('.slideshowOnOff').html() == 'off') {
		clearInterval(intervalID);	// Stop the slideshow
		intervalID = setInterval(function() {
			featuredSlideshowNextFrame();
		}, slideShowTime);
	}
}

function go_to_post(link){
    window.location = link;
}

