var duration = 6000; //Hier die Dauer zwischen den Überblendungen angeben (Millisekunden)
var fadeduration = 800; //Hier die Dauer der Überblendung angeben (Millisekunden)

$(document).ready(function() {
	
	//setInterval
	var setIndex=1;
	$("#container a").each(function() {
		$(this).attr("id","galleryimage"+setIndex);
		setIndex = parseInt(setIndex + 1);
	});
	$("#container a:first-child").addClass("active");
	$("#container a:first-child").show();

	var max = $("#container a").length;
	function next() {
		var activeId = $("#container .active").attr("id");
		var thisindex = parseInt(activeId.substring(12));
		var thatindex = thisindex;
		nextindex = thisindex + 1;
		if (nextindex>max) {
			nextindex=1;
		}

		$("#container #galleryimage"+thatindex).removeClass("active");
		$("#container #galleryimage"+thatindex).fadeOut(fadeduration);
		$("#container #galleryimage"+nextindex).fadeIn(fadeduration, function() {
			$(this).addClass("active");
		});	
	}
	
	var automaticAnimation = window.setInterval(next,duration);
	
});
