		var slider = new Class({
				initialize: function(params){
					this.indexnow = params.start || 0;
					this.imagewidth = params.width;
					this.images = params.images;
					this.images_id = params.images_id;
					this.images_toid = params.images_toid;
					this.images_link = params.images_link;
					this.image_steps = 3;
					//this.oldswitchimagecontent = '';
					this.indexnow = this.indexnow.toInt()
					
					// use this animation forslider effect
					Animation = new Fx.Tween('slider_box', {
						property: 'left',
						duration: 1000, 
						transition: Fx.Transitions.Quart.easeInOut
					});					
					
					this.infobox();
							
				
					//Display current image
					this.imageinject(this.images[this.indexnow],this.indexnow);
					
					//Jump to "first" image
					$('slider_box').setStyle('left', this.indexnow*-this.imagewidth);
					
					// Preload last/next Image
					this.preload();
		
					// Add links to thumbnail images (if exist)
					$$('[id=slider_jumppoint]').each(function(el){
			   				el.addEvent('click', function(e) {
			   					var event = new Event(e);
								event.preventDefault();
								this.jumpto(el.rel);
		   					}.bind(this))
	   				}.bind(this));

					
					if($('slider_next')) {
						// What happens if "next" button is clicked
						$('slider_next').addEvent('click',function(e){
							var event = new Event(e);
							event.preventDefault();
							this.indexnow += this.image_steps ;
							
							if(this.indexnow >= this.images.length) this.indexnow = 0;
							else if(this.indexnow > this.images.length-this.image_steps) this.indexnow = this.images.length-this.image_steps;
			
							
							goto = this.indexnow*-this.imagewidth;
							Animation.cancel();
							Animation.start(goto); 
							this.preload();
						}.bind(this));
					}
					
					if($('slider_last')) {
						// What happens if "last" button is clicked
						$('slider_last').addEvent('click',function(e){
							var event = new Event(e);
							event.preventDefault();
							this.indexnow -= this.image_steps;

							if(this.indexnow < 0 && this.indexnow+this.image_steps > 1) this.indexnow = 1;
							else if(this.indexnow < 0) this.indexnow = this.images.length-this.image_steps;

							goto = this.indexnow*-this.imagewidth;
							Animation.cancel();
							Animation.start(goto); 
							this.preload();
						}.bind(this));
					}
				},

			

				switchimage_add: function (content) {
					$$('a[id=switchimage]').each(function(el){

						el.addEvents({
							'click': function(e){
								var event = new Event(e);
								event.preventDefault();

							$('largeimage').set('src',el.rel);
							$('largeimage_url').set('href',el.rel);
							Slimbox.scanPage();
							}.bind(this)			

						});
					}.bind(this));

				},
				
				switchimage: function (content) {
					if(content) {
						this.oldswitchimagecontent = $('sliderimage_container'+this.indexnow).get('html');
						$('sliderimage_container'+this.indexnow).set('html','<img src="'+content+'" border="0" />');
					} else if(this.oldswitchimagecontent) {
						$('sliderimage_container'+this.indexnow).set('html',this.oldswitchimagecontent);
						this.oldhtmlcontent = '';
					}
					
					
				},
				
				imageinject: function (v,id) {
					// injects a image into DOM
					// $('sliderimage_container'+id).set('html','<img src="'+v+'" border="0" id="sliderimage'+id+'" />');
					var a_start = '';
					var a_end = '';
					
					if(this.images_link && this.images_link[id]) {
						a_start = '<a href="'+this.images_link[id]+'" rel="'+this.images_link[id]+'"  id="switchimage">';
						a_end = '</a>';
					}
					
					$('sliderimage_container'+id).set('html','<div class="sliderimage_image">'+a_start+'<img src="'+v+'" border="0" id="sliderimage'+id+'" />'+a_end+'</div><div class="sliderimage_image_info">'+(id+1)+'</div>');
					this.switchimage_add();										
				},

				preload: function () {
					
					loadnum = 5;
				
					// Preload next image - but only, if it isn't already loaded 
					imageload = this.indexnow;

					for (i = 0; i < loadnum; i++){ 
						if(imageload == this.images.length-1) var imageload = 0;
						else var imageload = imageload+1;
						if(!$('sliderimage'+imageload) && this.images[imageload]) this.imageinject(this.images[imageload],(imageload));
					}

					// Preload last image - but only, if it isn't already loaded 
					imageload = this.indexnow;
					for (i = 0; i < loadnum; i++){ 
						if(imageload == 0) var imageload = this.images.length-1;
						else var imageload = imageload-1;
						if(!$('sliderimage'+imageload) && this.images[imageload]) this.imageinject(this.images[imageload],(imageload));
					}
					
				},

				infobox: function () {
					// Updates the infobox with imagenumbers
					//if($('imagenumber')) $('imagenumber').set('html',(this.indexnow.toInt()+1)+' / '+this.images.length);	
					if($('imagenumber')) $('imagenumber').set('html',this.images.length+' Bilder insgesamt.');	
				},
	

				jumpto: function (id) {
						this.indexnow = id.toInt();
						this.imageinject(this.images[this.indexnow],this.indexnow);
						goto = this.indexnow*-this.imagewidth;
						Animation.cancel();
						Animation.start(goto); 
						this.preload();
				}



		});	
