function Slideshow(id,delay,speed)
{
	this.act = 1;
	this.id = id;

	if(speed)
		this.speed = speed;
	else
		this.speed = 3000;

	if(delay)
		this.delay = Math.ceil(this.speed/2);
	else
		this.delay = 0;

	this.moveSpeed = 1000;
	this.easing = "swing";
	this.zindex_active = 15;
	this.zindex_inactive = 5;

	this.objects = $("#"+this.id+" li").length;

	if(this.objects > 1)
	{
		$("#"+this.id+" li").css("z-index",this.zindex_inactive).hide();
		$("#"+this.id+" li:nth-child(1)").css("z-index",this.zindex_active).show();

		this.startSlideshow = slideshowStartSlideshow;
		this.slideNext = slideshowSlideNext;

		var instant = this;
		setTimeout(function() { instant.startSlideshow(); },this.speed-this.delay);
	}
}

function slideshowStartSlideshow()
{
	var instant = this;
	instant.slideNext();
	this.slideshow = setInterval(function() { instant.slideNext(); },this.speed);
}

function slideshowSlideNext()
{
	$("#"+this.id+" li:nth-child("+this.act+")").css("z-index",this.zindex_active).fadeOut(this.moveSpeed);
	if(this.act < this.objects)
		this.act++;
	else
		this.act = 1;
	$("#"+this.id+" li:nth-child("+this.act+")").css("z-index",this.zindex_inactive).fadeIn(this.moveSpeed);
}

if($("#slideshowLeft"))
	new Slideshow("slideshowLeft",true);

if($("#slideshowRight"))
	new Slideshow("slideshowRight");

if($("#slideshowNotizbuecherMoleskine"))
	new Slideshow("slideshowNotizbuecherMoleskine",true);

if($("#slideshowNotizbuecherLeuchtturm"))
	new Slideshow("slideshowNotizbuecherLeuchtturm");

if($("#slideshowKalenderMoleskine"))
	new Slideshow("slideshowKalenderMoleskine",true);

if($("#slideshowKalenderLeuchtturm"))
	new Slideshow("slideshowKalenderLeuchtturm");


