			var BrunelCarousel = new Class({
			
			/* 
			   Brunel Carousel (requiring MooTools)
			   Carsten Meyer
			   HMMH AG 2011
			   
			*/	
			
						initialize: function(timeout,duration,direction,callback){
						
							if(callback) new callback();
							this.timeout = timeout;
							this.duration = duration;
							this.direction = direction;
							this.allowclick = true;
							
							_BrunelSlideShow = this;
							this.slides = $$('.CarouselPage');
							this.slideshowbox = $(this.slides[0].parentNode);
							
							this.slideArray = new Array();
							this.buttons = new Array();
							
							this.slides.each(function(obj,nr){
							
								obj.nr = nr;
								this.slideArray.push(nr);
								obj.setStyle('z-index',999 - nr)
							
							}.bind(this));
							
							this.setCounter();
							this.timer = setTimeout(this.start,5000);
						
						},
						
						slideInOut: function(nr,mode){
						
							slider = this.slides[nr];
							try{
							var w = slider.getSize().x;
							}catch(e){}
							
							slider.setStyle('z-index',1000);
							
							var myFx = new Fx.Tween(slider, {
								duration: this.duration,
								transition: 'expo:InOut',
								//link: 'cancel',
								property: 'left'
							});
							
							if(mode == 'in'){
							slider.setStyles({
							'z-index':1000,
							'left' : -w
							
							}
							);
							myFx.start((w * this.direction),0).chain(function(){
							

								this.slideArray.push(this.slideArray.shift());
								if(this.timer) clearTimeout(this.timer);
								this.timer = setTimeout(this.start,this.timeout);
								_BrunelSlideShow.allowclick  = true;
							
							
							}.bind(this));
							}
							else
							myFx.start(0,(-w * this.direction));
						
						},
						
						start: function(){
						
							
							
							first = _BrunelSlideShow.slideArray[0];
							if(first == _BrunelSlideShow.slideArray.length -  1)
							second = 0;
							else
							second = first + 1;
							
							_BrunelSlideShow.slideInOut(first,'out');
					        _BrunelSlideShow.slideInOut(second,'in');
							_BrunelSlideShow.updateNavigation();
						
						},
						
						updateNavigation: function(){
						
						
							_BrunelSlideShow.buttons.each(function(obj,nr){
							
								obj.removeClass('ccounter-active');
							
							});
							_BrunelSlideShow.buttons[second].addClass('ccounter-active');
						
						
						},
						
						
						gotoSlide: function(nr){
								
							second = nr;
							first = _BrunelSlideShow.slideArray[0];
							_BrunelSlideShow.updateNavigation();

							_BrunelSlideShow.slideInOut(first,'out');
					        _BrunelSlideShow.slideInOut(second,'in');
						    
							while(_BrunelSlideShow.slideArray[1] != nr){
							_BrunelSlideShow.slideArray.push(_BrunelSlideShow.slideArray.shift());
							}
						    
						},
						
						
						
					setCounter: function(posclass){
					
						var div = new Element('div',{
						
							'class': posclass,
							'id': 'carousel-navigation',
							'styles':{
							
								'width': '270px',
								'position': 'absolute',
								'right': '0px',
								'bottom': '210px',
								'z-index': 1000
							}
						
						});
						
						this.slideArray.each(function(obj,nr){
						

							var a = new Element('a',{
							
								'html': ' ',
								'href':  'javascript:void(0)',
								'class': 'ccounter',
								'events':{
								
									'click': function(){
										if(!this.hasClass('ccounter-active') && _BrunelSlideShow.allowclick )
										{		
										 clearTimeout(_BrunelSlideShow.timer);
										_BrunelSlideShow.gotoSlide(this.nr);
										}
										_BrunelSlideShow.allowclick = false;
										
									}
								}
							
							}).inject(div);
							a.setStyle('outline',0);
							_BrunelSlideShow.buttons.push(a);
							
							
							if(nr == 0) a.set('class','ccounter ccounter-active');
							a.nr = nr;
						
						});
						
						div.inject(this.slideshowbox);
					
					}
			
			});
			
var BrunelSlideShow = new Class({


	initialize: function(){
	

		
		$$('div.CarouselSwitchLabel').each(function(obj,nr){
		
		    var h = obj.getSize().y + 20;
			var posy = ((320 - h)/2).toInt();
			var posy = 50;
			obj.setStyle('height', h +'px');
			obj.setStyle('top', posy +'px');
			
			obj.getElement('div.text').setStyles({
			
				'position':'absolute',
				'left': '15px',
				'top': '15px',
				'width': obj.getSize().x - 30 + 'px',
				'z-index': 10
			});
			
			obj.getElement('a.switch').setStyle('height', h - 10 + 'px');

			
			new Element('div',{
			
				'html':'',
				'styles':{
				
					'position':'absolute',
					'height': h + 'px',
					'width': obj.getSize().x + 'px',
					'background-color': '#ffffff',
					'opacity': 0.9,
					'left':'0px',
					'top':'0px',
					'z-index': 0
				
				}
			
			}).inject(obj,'top');
		});
	
	}

});

			
			window.addEvent('load',function(){
			
			            
						var slideshow = new BrunelCarousel(5000,700,1,BrunelSlideShow); // Verzögerung in ms, Slide-Geschw. in ms, Richtung (-1: nach rechts, 1: nach links), Callback-Klasse 
						
						

						
			
			});
