/**
var nActualImage;
var nImages;
var nImageWidth;

// Initialize the slideshow
function initSlideShow() {

	if ($('galleryMover')) {
		nActualImage = 1;
		nImageWidth = 555;
		
		nImages = $('galleryMover').getElementsByTagName("img").length;
		
		// Remove no-script fallback css
		$('galleryMover').width = nImages * nImageWidth;
		$('galleryImageWrapper').setStyle({
			overflow: 'hidden'
		});
		$('leftButton').setStyle({
			display: 'block'
		});
		$('rightButton').setStyle({
			display: 'block'
		});	
	}
}

// Function to show next images
function nextImage() {
	
	// if there is a "next" image left
	if (nActualImage < nImages) {
		
		var nPos = - nImageWidth * nActualImage;
		moveImageWrapper(nPos);
		
		nActualImage ++;
	
	// else scroll back to the first one
	} else {
		
		var nPos = 0;
		moveImageWrapper(nPos);
		
		nActualImage = 1;
	}
}

// Function to show previous images
function previousImage() {
	
	// if there is a "previous" image left
	if (nActualImage > 1) {
		
		nActualImage --;
		
		var nPos = - nImageWidth * (nActualImage-1);
		moveImageWrapper(nPos);
		
		
		
	// else scroll to the last one
	} else {
		
		var nPos = - nImageWidth * (nImages-1);
		moveImageWrapper(nPos);
		
		nActualImage = nImages;

	}
}

// The move effect itself
function moveImageWrapper(nPos) {
	
	new Effect.Morph('galleryMover', {
			style: 'margin:0 0 0 '+nPos+'px'
		});

}

// Initialize slideshow on load
Event.observe(window, 'load', initSlideShow, false);**/


var BayernSlider = Class.create();
Object.extend(Slider.prototype, {
	initialize:function(id, type)
	{
		this.id = id;
		this.sliderGroup = $(id);
		this.sliderWrapper = this.sliderGroup.parentNode;
		this.wrapper = this.sliderWrapper.parentNode;
		this.slides = $$('#' + this.sliderGroup.id + ' li');
		this.type = type;
		
		this.maxWidth = 0;
		this.counter = 0;
		this.slides.each(function(slide) {
			this.maxWidth += slide.offsetWidth;
			this.counter++;
		}.bind(this));
		this.slideWidth = this.maxWidth / this.counter;
		
		this.sliderGroup.style.width = this.maxWidth + "px";
		
		if(this.counter > 1) {
		
			if(this.type == 'related') {
			
				this.jumpToCurrent();
			
			}
		
			this.reverseButton = new Element('a', {'href': 'javascript:void(0)', 'class': 'leftSliderNav sliderNav pngIE'}).update('zurück');
			this.forwardButton = new Element('a', {'href': 'javascript:void(0)', 'class': 'rightSliderNav sliderNav pngIE'}).update('vor');
			
			this.wrapper.appendChild(this.reverseButton);
			this.wrapper.appendChild(this.forwardButton);
		
			this.reverse = this.reverse.bindAsEventListener(this);
			this.forward = this.forward.bindAsEventListener(this);
		
			Event.observe(this.reverseButton, 'click', this.reverse);
			Event.observe(this.forwardButton, 'click', this.forward);
		}
		
	},
	reverse:function(event)
	{
		Event.stopObserving(this.reverseButton, 'click', this.reverse);
		
		fx = new Effect.Move(this.sliderGroup, {
			x: this.slideWidth, 
			mode: 'relative', 
			duration: 0.5, 
			beforeStart:function() {
				this.sliderGroup.style.left = "-" + this.slideWidth + "px";
				Element.insert(this.sliderGroup, {top: $$('#' + this.sliderGroup.id + ' li')[this.counter - 1]});
			}.bind(this),
			afterFinish:function() {
				Event.observe(this.reverseButton, 'click', this.reverse);
			}.bind(this)
		});
	},
	forward:function(event)
	{
		Event.stopObserving(this.forwardButton, 'click', this.forward);
		
		fx = new Effect.Move(this.sliderGroup, {
			x: -this.slideWidth,
			mode: 'absolute', 
			duration: 0.5,
			afterFinish:function() {
				Event.observe(this.forwardButton, 'click', this.forward);
				this.sliderGroup.appendChild($$('#' + this.sliderGroup.id + ' li')[0]);
				this.sliderGroup.style.left = "0px";
			}.bind(this)
		});
	},
	jumpToCurrent:function()
	{
		var flag = false;
		
		this.slides.each(function(elm) {
			if(elm.id.split("_")[1] != elm.className.split("_")[1] && flag === false) {
				this.sliderGroup.appendChild($$('#' + this.sliderGroup.id + ' li')[0]);
			} else {
				flag = true;
			}
		}.bind(this));
	}
});
