

		/*
		    @license: GNU/GPL
			@author: Nils M. Petersohn
			
			Nils M. Petersohn
			snackycracky.wordpress.com
			xing.com/profile/Nils_Petersohn
			myspace.com/electrash
			twitter.com/snackycracky
			facebook.com/nils.petersohn
			
			nils@schoenhouse.de
			0049 (0)177 6311074
			skype: nilz_berlin
			icq: 99510895
			
			Ebertystr. 47
			10249 Berlin

		*/

			$$('div.article-content').each(function(el){el.hide();});	


			if (Object.isUndefined(Cygl)) { var Cygl = { } }
			
			Cygl.Slideshow = Class.create({
				
				initialize: function() {
					this.options = Object.extend({
						images: $$('div.article-content img[title]'),
						text:   $$('div.article-content ul li'),
						container: $('slideshowWrapper'),
						completeLoops: 5, //2 heisst bei 10 bildern ca. 10 min.
						duration: 4, 
						showTime: 12
					}, arguments[0] || { });
					
					var that = this;	
					this.start = true;
					this.faster = false;
					this.delay = 0;
					this.delayText = 0;
					this.orginalSize = this.options.container.getStyle('width').replace("px","");
					
					this.options.images.each(function(el){el.hide();});
					this.options.text.each(function(el){el.hide()});
					
					var cont = this.options.container;
					var z = this.options.images.length;
					
					this.options.text.each(function(el){
						internalContainer = new Element('div', { 'class': 'quoteContainer','style':'z-index:1000;display:none'})
						internalContainer.insert(new Element('span', { 'class': 'quote'  }).update(el.innerHTML));//
						cont.insert(internalContainer);
					});
					this.options.images.each(function(el){
						internalContainer = new Element('div', { 'class': 'imageContainer','style':'z-index:' + z-- })
						internalContainer.insert(new Element('img', { 'class': 'sildeshowImage', src: "/"+el.title }));
						cont.insert(internalContainer);
					});	
					
					
					
					this.loop();
					
				},
				
				loop: function(){
					
					var cont = this.options.container;
					var that = this;	
					var switcher = false;
					
					var images = $$('div.imageContainer');
					var quotes = $$('div.quoteContainer');
					var j=1;
					$R(1 ,this.options.completeLoops * images.length ).each(function(i){
											
						images.each(function(el){ 
							
							if(el.getStyle('z-Index') != 1)  that.moveEl(el,switcher);
							if(j % that.options.images.length == 0)  switcher = !switcher;
							
							j++;
							
						});
						
						images.reverse();
						
						quotes.each(function(el){
							that.moveElText(el,switcher);
						});
						
					});
					
				},
				
				moveEl: function(el,direction){
					
					//$('delay').innerHTML += el.getStyle('z-Index')+" "+el.childElements()[0].src +"<br>";
					
					//$('delay').innerHTML += this.delay +" "//"moving "+el.childElements()[0].src+" to "+((!direction)?'0':this.orginalSize)+"px<br>";;
						
					new Effect.Morph(el,{style: {width: ((!direction)?'0':this.orginalSize)+'px' }, delay:this.delay, duration:this.options.duration});
					
					this.delay = this.delay + this.options.duration + this.options.showTime;
					
					
					var that = this;
					if(this.start){
						$$('div.quoteContainer').each(function(el){
							that.moveElText(el,direction);
						});
						this.start = false;
					}
					
				},
				
				moveElText: function(el,direction){
					
					new Effect.Appear(el, { delay:this.delayText, duration:this.options.duration , queue: 'end' } );
					new Effect.Fade(el,  { delay:this.delayText + this.options.showTime / 2 , duration:this.options.duration, queue: 'end' });
					this.delayText = this.delayText + this.options.duration  ;
					
				}
			});
			
			
			
			Event.observe(window, 'load', function() {
			  $$('div.article-content').each(function(el){el.show();});							   
			  new Cygl.Slideshow() ;
			  new Effect.Fade('cover', {duration:4});
			});
			
