// --- START SLIDESHOW CODE ---

var siteFeaturesDelay = 5000;

var siteFeatures = null;
var featureIndex = 0;
var isFocused = 0;

$(document).ready(function() {
	
    siteFeatures = $(".slideshow .slide").hide().size();
    $(".slideshow .slide:eq(" + featureIndex + ")").show();
    $(".slideshow").hover(function() {
    	isFocused = 1;
    }, function() {
    	isFocused = 0;
    });
    setInterval(updateSiteFeatures, siteFeaturesDelay);
});

function updateSiteFeatures() {
	if (isFocused) return;
    $(".slideshow .slide:eq(" + featureIndex + ")").fadeOut('slow', function() {
    	$(this).hide();
    	featureIndex = (featureIndex + 1) % siteFeatures;
    	$(".slideshow .slide:eq(" + featureIndex + ")").show().fadeIn('slow');
    });
}

