function slider(name,max,namen)
{
	var step=0;
	var oldstep=0;
	var slide_step = 0;
	var currentTimeout = null;
	var slidetimeout = null;
	var scrollspeed = 50;
	var slidespeed = 4000;
	var autoscroll = false;
	
	this.getstep = function()
	{
		return step;
	}
	
	this.next_image = function(orientation, stop)
	{
		if (stop == 1)
		{
			clearTimeout(currentTimeout);
			clearTimeout(slidetimeout);
								
		}
		if (typeof(orientation) == "undefined")
		{
			var orientation=0;
		}

		
		if (step >= max)
		{
			oldstep = step;
			step = -1;
		}
	
	
		var caller = this;
		var set_orientation = orientation;
		
		slidetimeout = setTimeout(function() {
			caller.slide(set_orientation);
		},scrollspeed);
		
	}

	this.slide = function(orientation)
	{
		if (typeof(orientation) == "undefined")
		{
			var orientation=0;
		}

		if (slide_step <= 15)
		{

			if (step == -1) //zum anfang scrollen
			{
				document.getElementById(name).style.marginLeft = ((oldstep * 150 * -1 ) + (slide_step * 10 * oldstep)) + "px";
			}
			else if(orientation == 1) // rückwärts
			{
				if (step != 0)
				{
					document.getElementById(name).style.marginLeft = ((step * 150 * -1) + slide_step * 10) + "px";
				}
			}
			else // vorwärts
			{
				document.getElementById(name).style.marginLeft = ((step * 150 * -1) - slide_step * 10) + "px";
			}
			slide_step++;

				

			
			var caller = this;
			var set_orientation = orientation;
			
			slidetimeout = setTimeout(function() {
				caller.slide(set_orientation);
			},scrollspeed);
		}
		else
		{
			slide_step=0;
			if (orientation==0)
			{
				step++;
			}
			else if (step>0)
			{
				step--;
			}
			if (step > 0 && step <= max){
				document.getElementById("slider_pfeil_links").style.display = "block";
			}
			else {
				document.getElementById("slider_pfeil_links").style.display = "none";
			}
			
			document.getElementById(name + "_text").innerHTML = namen[step];
			var caller = this;
			
			if (autoscroll == true)
			{
				currentTimeout = setTimeout(function() { 
						caller.next_image(); 
						},slidespeed);
			}
		}
		
	}
	var caller = this;
	if (autoscroll == true)
	{
	currentTimeout = setTimeout(function() { 
						caller.next_image(); 
						},slidespeed);
	}
};
