var SimpleSlideShowDemo = new Class({
	options: {
		slides: [],
		startIndex: 0,
		wrap: true,
		onShow: Class.empty, //Mootools 1.2: $empty
		onRotate: Class.empty,
		onStop: Class.empty,
		onAutoPlay: Class.empty,
		onShowSlide: Class.empty,
		slideInterval: 4000,
		auto:false,
		transitionDuration: 1000,
		splitter:"&middot;",
		prev:"&laquo; ",
		next:" &raquo",
		play:"&infin;",
		stop:"&phi;",
		bigNavigation : true,
		smallNavigation: true,
		browser:true,
		addBarInside:true,
		hideText:false

	},
	initialize: function(container,options){

	  if (container[0].getParent().getTag()=='a') {
     this.containerNest = container[0].getParent().getParent();
    } else {
      this.containerNest = container[0].getParent();
    }
    this.container = container;
		this.setOptions(options);
		this.slides = [];
		this.title = [];
		this.descr = [];
		this.effects = [];
		this.effectspos = [];
		this.effectshg = [];
		this.effectstop = [];
		this.browserArr = [];
		this.playStatus = false;
		if (this.options.auto) this.playStatus = true;

    this.createStructure();

		this.addSlides(this.container);
		if(this.slides.length) this.showSlide(this.options.startIndex);
		if (this.options.auto) {
      this.autoplay();
     // this.playStatus = true;
    }
	},
	createFx: function(){
		this.slideFx = new Fx.Elements(this.slides, {duration: this.options.transitionDuration});
		//this.slideFx = new Fx.Elements(this.slides, {fps: 20});
		
    this.slides.each(function(slide){
			slide.setStyle('opacity',0);
			slide.setStyle('top','45px');
			slide.setStyle('height','60px');
			
		});
	},	
	createStructure: function() {

	  var oldClass = this.containerNest.getProperty("class");
    this.containerNest.setProperty('class', '');
	  this.containerNest.addClass('rgslideshow');
	  this.containerNest.addEvent('mouseover', this.stopHover.bind(this));
	  //this.containerNest.addEvent('mouseout', this.autoplay.bind(this));
	  this.containerNest.addEvent('mouseout', this.playHover.bind(this));
	  
	  this.test = new Element('div').addClass(oldClass).injectBefore(this.containerNest);
	  
    this.containerNest.injectInside(this.test);
	  
	  if (!this.options.hideText) {
	  
      if (this.options.addBarInside) {
        this.nestAll = new Element('div').setProperty('class', 'rgsnest').injectTop(this.containerNest);    
        this.title = new Element('div').setProperty('class', 'rgstitle').injectInside(this.nestAll);
        this.description = new Element('div').setProperty('class', 'rgsdescription').injectInside(this.nestAll);
      }
      
      //	  this.nestAll = new Element('div').setProperty('class', 'rgslideshow').injectAfter(this.containerNest);
      
      // if (this.options.addBarInside) this.titleOp = new Element('div').setProperty('class', 'optitle').injectInside(this.nestAll);
    //  this.nestDescription = new Element('div').setProperty('class', 'descr').injectInside(this.nestAll);
    //  if (this.options.addBarInside) this.descriptionOp = new Element('div').setProperty('class', 'opdescr').injectInside(this.nestAll);
      
   
       if(this.options.browser) {
       
        this.navigation = new Element('div').setProperty('class', 'rgslideshownav').injectAfter(this.containerNest);
        this.innerNavigation = new Element('div').setProperty('class', 'rgsnav2').injectInside(this.navigation);
        
        if(this.options.smallNavigation) this.prevEl = new Element('span').setProperty('class', 'rgsprev').injectInside(this.innerNavigation).setHTML(this.options.prev).addEvent('click', this.cycleBack.bind(this));
        this.browser = new Element('div').setProperty('class', 'rgsbrowser').injectInside(this.innerNavigation);
       if(this.options.smallNavigation)  this.nextEl = new Element('span').setProperty('class', 'rgsnext').injectInside(this.innerNavigation).setHTML(this.options.next).addEvent('click', this.cycleForward.bind(this));
  
        this.play = new Element('span').setProperty('class', 'rgsplay').injectInside(this.innerNavigation).addEvent('click', this.togglePlay.bind(this));    
      // this.play = new Element('span').setProperty('class', 'rgsplay').injectInside(this.innerNavigation).addEvent('click', this.togglePlay.bind(this));    
  //this.containerNest.addEvent('mouseover', this.togglePlay.bind(this));
        if (!this.playStatus) {
          this.play.setHTML(this.options.play).setProperty('title',"Play");
        } else {
          this.play.setHTML(this.options.stop).setProperty('title',"Stop");
        }
       } 
    } 

    if (this.options.bigNavigation) {
      //this.bigPrev = new Element('a').setProperties({'class': 'rgsbigprev', 'href': "javascript:void(0);"}).injectInside(this.containerNest).addEvent('click', this.cycleBack.bind(this));
      //this.bigNext = new Element('a').setProperties({'class': 'rgsbignext', 'href': "javascript:void(0);"}).injectInside(this.containerNest).addEvent('click', this.cycleForward.bind(this));
     // this.bigPrev = new Element('a').setProperties({'class': 'rgsbigprev', 'href': "javascript:void(0);"}).injectInside(this.containerNest).addEvent('mouseover', this.autobw.bind(this));
     // this.bigNext = new Element('a').setProperties({'class': 'rgsbignext', 'href': "javascript:void(0);"}).injectInside(this.containerNest).addEvent('mouseover', this.autofw.bind(this));
      this.bigPrev = new Element('a').setProperties({'class': 'rgsbigprev', 'href': "javascript:void(0);"}).injectInside(this.containerNest).addEvent('mouseover', this.cycleBack.bind(this));
      this.bigNext = new Element('a').setProperties({'class': 'rgsbignext', 'href': "javascript:void(0);"}).injectInside(this.containerNest).addEvent('mouseover', this.cycleForward.bind(this));
    
    this.bigplaystop = new Element('span').setProperty('class', 'rgsplay').injectInside(this.containerNest).addEvent('click', this.togglePlay.bind(this));    
    this.bigplaystop.setStyles({'position':'absolute' , right: 0 ,visibility:'hidden'});
         if (!this.playStatus) {
          this.bigplaystop.setHTML(this.options.play).setProperty('title',"Play");
        } else {
          this.bigplaystop.setHTML(this.options.stop).setProperty('title',"Stop");
        }
    }    
    
    this.createFx();

  },
	addSlides: function(slides){
    var i =1;

		slides.each(function(slide){
			this.slides.include($(slide));

			this.effects[this.slides.indexOf(slide)] = new Fx.Style(slide, 'opacity');
      this.effectspos[this.slides.indexOf(slide)] = new Fx.Style(slide, 'left');
      this.effectshg[this.slides.indexOf(slide)] = new Fx.Style(slide, 'height');
      this.effectstop[this.slides.indexOf(slide)] = new Fx.Style(slide, 'top');
      slide.addClass('rgssimg');
        var title="&nbsp;";
        var descr="";
        if (slide.getProperty("title")) {
          split = slide.getProperty("title").split("|");
          if (split[0]) {
            title = split[0];
            slide.setProperty("title",title);
          }
          if (split[1]) descr = split[1];
        }

  			this.descr[this.slides.indexOf(slide)] = descr;      
  			this.title[this.slides.indexOf(slide)] = title;
      if(this.options.browser) {  			
        this.browserEl = new Element('span').setProperties({'class': 'rgsbrowserEl', 'title': title}).setHTML(this.slides.indexOf(slide)+1).injectInside(this.browser);
    //    this.browserEl.setProperty('id',this.options.paginationSelector+i);
  			this.browserEl.addEvent('click', this.cycleTo.bind(this,this.slides.indexOf(slide)));
  			this.browserArr[this.slides.indexOf(slide)] = this.browserEl;
  		}
			
			if (i!=1) {
      	if(this.options.browser)		this.splitter = new Element('span').setProperty('class', 'rgssplitEl').setHTML(this.options.splitter).injectBefore(this.browserEl);
      	slide.setStyle('display','block');      
        slide.setStyle('opacity','0');	
      } else {

        if (!this.options.hideText && this.options.addBarInside) {
          var nestDiv = this.nestAll.getSize();
        } else {
          var nestDiv = this.containerNest.getSize();

        }
        var img = slide.getSize();

    		if(this.options.bigNavigation) {          
          this.bigPrev.setStyle('height','30px');
          this.bigNext.setStyle('height','30px');
          /*
          this.bigPrev.setStyle('height',(slide.getProperty("height")-nestDiv.size.y)+'px');
          this.bigNext.setStyle('height',(slide.getProperty("height")-nestDiv.size.y)+'px');
          if(!this.options.addBarInside) {
	          this.bigPrev.setStyle('height',(slide.getProperty("height"))+'px');
	          this.bigNext.setStyle('height',(slide.getProperty("height"))+'px');

					}
          	*/				 
        }
    		if(this.options.addBarInside) { 
    		  /*
          this.nestAll.setStyle('width',slide.getProperty("width")+'px');
    		*/
        }
    	  if(this.options.browser) {
          var width =  this.containerNest.getSize();
    		  this.navigation.setStyle('width',width.size.x-1+'px');
        }
      
      }
			i++;
		}, this);
	},
	addSlide: function(slide){
		this.addSlides([slide]);
	},
	cycleForward: function(){
		if($chk(this.now) && this.now < this.slides.length-1) this.showSlide(this.now+1);
		else if ((this.now) && this.options.wrap) this.showSlide(0);
		else if(!$defined(this.now)) this.showSlide(this.options.startIndex);
		
    this.bigNext.setStyle('display', 'none');
    this.bigPrev.setStyle('display', 'none');
		
	},
	cycleBack: function(){
		if(this.now > 0) this.showSlideBack(this.now-1);
		else if(this.options.wrap) this.showSlideBack(this.slides.length-1);
		
		this.bigNext.setStyle('display', 'none');
    this.bigPrev.setStyle('display', 'none');
	},
	
	cycleTo: function(i){
		if(this.playStatus) {
      this.togglePlay();
    }	
    this.showSlide(i);
	},
	togglePlay: function() {
    if (this.playStatus) {
      this.stop();
      this.playStatus = false;
      //this.play.innerHTML = this.options.play;
      //this.play.setProperty('title',"Play");
      this.bigplaystop.innerHTML = this.options.play;
      this.bigplaystop.setProperty('title',"Play");
    }
    else {
      this.autoplay();
      this.playStatus = true;
      //this.play.innerHTML = this.options.stop;
      //this.play.setProperty('title',"Stop");
      this.bigplaystop.innerHTML = this.options.stop;
      this.bigplaystop.setProperty('title',"Stop");
    }
  },
	autoplay: function(){
		this.bigNext.setStyle('visibility', 'hidden');
    this.bigPrev.setStyle('visibility', 'hidden');
    
		this.slideshowInt = this.rotate.periodical(this.options.slideInterval, this);
		this.fireEvent('onAutoPlay');
	},
	playHover: function(){
  	if (this.playStatus) {
  		this.bigNext.setStyle('visibility', 'hidden');
      this.bigPrev.setStyle('visibility', 'hidden');
      
  		this.slideshowInt = this.rotate.periodical(this.options.slideInterval, this);
  		this.fireEvent('onAutoPlay');
  	}
  },
	autofw: function(){
		clearInterval(this.slideshowInt);
    this.slideshowInt = this.rotate.periodical(this.options.slideInterval, this);
		this.fireEvent('onAutoPlay');
	},
		autobw: function(){
	clearInterval(this.slideshowInt);
		
  	this.slideshowInt = this.rotateback.periodical(this.options.slideInterval, this);
		this.fireEvent('onAutoPlay');
	},
	stop: function(){
		clearInterval(this.slideshowInt);
		this.fireEvent('onStop');
	},  
  stopHover: function(){
    this.bigNext.setStyle('visibility', 'visible');
    this.bigPrev.setStyle('visibility', 'visible');
    
		clearInterval(this.slideshowInt);
		this.fireEvent('onStop');
	}, 	
	rotate: function(){
		this.cycleForward();
		this.fireEvent('onRotate');
	},
  rotateback: function(){
		this.cycleBack();
		this.fireEvent('onRotate');
	},	
	showSlide: function(iToShow){

		var now = this.now;		
		var currentSlide = this.slides[now];
		var slide = this.slides[iToShow];

		
		function fadeIn(s){
			s.setStyles({
				display:'block',
				visibility: 'visible',
				opacity: '1',
				left:'195px',
				height:'100px',
				top: '5px'
			});
			s.setStyle('z-index', '100');
			//this.effects[this.slides.indexOf(s)].start('0.5');
			//this.effectspos[this.slides.indexOf(s)].start('355px');
			this.fireEvent('onShow', [slide, iToShow]);
		};
    
    if (!this.options.hideText) {
      if (this.options.addBarInside) this.description.innerHTML = this.title.innerHTML = "&nbsp;";
      if(this.options.browser) {
        this.browserArr.each(function(el) {
          el.removeClass("rgsact");
        });
      }
    }
    
    //this.effectspos[now+1].start('390px');    
    //this.effects[now+1].start('0');
    if(now >= 0){
      switch(now)
      {
      case 0:
          //-1
          this.effectspos[this.slides.length-1].start('0px');    
          this.effects[this.slides.length-1 ].start('0');
          this.effectshg[this.slides.length-1].start('60px');
          this.effectstop[this.slides.length-1].start('45px');  
          //-2
          this.effectspos[this.slides.length-2 ].start('390px');
          this.effects[this.slides.length-2].start('0');
          //+1
          this.slides[1].setStyle('z-index', '100');
          this.effectshg[1].start('100px');
          this.effectspos[1].start('195px');
          this.effectstop[1].start('5px');          
          this.effects[1].start('1');  
          //+2
          this.effectspos[2].start('355px');
          this.effects[2].start('0.5');  
          this.effectshg[2].start('80px');
          this.effectstop[2].start('25px'); 
          //+3
          this.effectspos[3].start('390px');
          this.effects[3].start('0');  
          this.effectshg[3].start('60px');
          this.effectstop[3].start('45px'); 
        break;
      case 1:
          //-1
          this.effectspos[0].start('0px');    
          this.effects[0].start('0');
          this.effectshg[0].start('60px');
          this.effectstop[0].start('45px'); 
          //-2
          this.effectspos[this.slides.length-1].start('390px');    
          this.effects[this.slides.length-1 ].start('0');
          //+1
          this.slides[2].setStyle('z-index', '100');
          this.effectshg[2].start('100px');
          this.effectspos[2].start('195px'); 
          this.effectstop[2].start('5px');
          this.effects[2].start('1');
          //+2
          this.effectspos[3].start('355px');    
          this.effects[3].start('0.5');
          this.effectshg[3].start('80px');
          this.effectstop[3].start('25px'); 
          //+3
          this.effectspos[4].start('390px');    
          this.effects[4].start('0');
          this.effectshg[4].start('60px');
          this.effectstop[4].start('45px'); 
        break;
      case (this.slides.length-3) :
          //-1
          this.effectspos[this.slides.length-4].start('0px');    
          this.effects[this.slides.length-4].start('0');
          this.effectshg[this.slides.length-4].start('60px');
          this.effectstop[this.slides.length-4].start('45px'); 
          //-2
          this.effectspos[this.slides.length-5].start('390px');    
          this.effects[this.slides.length-5 ].start('0');
          //+1
          this.slides[this.slides.length-2].setStyle('z-index', '100');
          this.effectshg[this.slides.length-2].start('100px');
          this.effectspos[this.slides.length-2].start('195px');
          this.effectstop[this.slides.length-2].start('5px');   
          this.effects[this.slides.length-2].start('1');
          //+2
          this.effectspos[this.slides.length-1].start('355px');
          this.effectshg[this.slides.length-1].start('80px');          
          this.effectstop[this.slides.length-1].start('25px');   
          this.effects[this.slides.length-1].start('0.5');
          //+3
          this.effectspos[0].start('390px');    
          this.effects[0].start('0');
          this.effectshg[0].start('60px');
          this.effectstop[0].start('45px'); 
        break;
      case (this.slides.length-2) :
          //-1
          this.effectspos[this.slides.length-3].start('0px');    
          this.effects[this.slides.length-3].start('0');
          this.effectshg[this.slides.length-3].start('60px');
          this.effectstop[this.slides.length-3].start('45px'); 
          //-2
          this.effectspos[this.slides.length-4].start('390px');    
          this.effects[this.slides.length-4 ].start('0');
          //+1
          this.slides[this.slides.length-1].setStyle('z-index', '100');
          this.effectshg[this.slides.length-1].start('100px');
          this.effectspos[this.slides.length-1].start('195px');
          this.effectstop[this.slides.length-1].start('5px');   
          this.effects[this.slides.length-1].start('1');
          //+2
          this.effectspos[0].start('355px');    
          this.effects[0].start('0.5');
          this.effectshg[0].start('80px');
          this.effectstop[0].start('25px'); 
          //+3
          this.effectspos[1].start('390px');    
          this.effects[1].start('0');
          this.effectshg[1].start('60px');
          this.effectstop[1].start('45px'); 
        break;
      case (this.slides.length-1):
          //-1
           this.effectspos[this.slides.length-2].start('0px');    
          this.effects[this.slides.length-2].start('0');
          this.effectshg[this.slides.length-2].start('60px');
          this.effectstop[this.slides.length-2].start('45px'); 
          //-2
          this.effectspos[this.slides.length-3].start('390px');
          this.effects[this.slides.length-3].start('0');
          //+1
          this.slides[0].setStyle('z-index', '100');
          this.effectshg[0].start('100px');
          this.effectspos[0].start('195px');
          this.effectstop[0].start('5px');
          this.effects[0].start('1');  
          //+2
          this.effectspos[1 ].start('355px');
          this.effects[1].start('0.5');  
          this.effectshg[1].start('80px');
          this.effectstop[1].start('25px'); 
          //+3
          this.effectspos[2 ].start('390px');
          this.effects[2].start('0');  
          this.effectshg[2].start('60px');
          this.effectstop[2].start('45px'); 
        break;    
      default:
          //-1
          
          
          this.effectspos[now-1].start('0px');    
          this.effects[now-1 ].start('0');
          this.effectshg[now-1 ].start('60px');
          this.effectstop[now-1 ].start('45px'); 
          //-2
          this.effectspos[now-2 ].start('390px');
          this.effects[now-2].start('0');          
          //+1
          this.slides[now+1].setStyle('z-index', '100');
          this.effectshg[now+1].start('100px');
          this.effectspos[now+1].start('195px');
          this.effectstop[now+1].start('5px');
          this.effects[now+1].start('1');  
          //+2
          this.effectspos[now+2 ].start('355px');
          this.effects[now+2].start('0.5');  
          this.effectshg[now+2].start('80px');
          this.effectstop[now+2].start('25px'); 
          //+3
          this.effectspos[now+3 ].start('390px');
          this.effects[now+3].start('0');  
          this.effectshg[now+3].start('60px');
          this.effectstop[now+3].start('45px'); 
      }
    }else{
    //erstes laden
    
        /*
          for (var i = 0;i<this.slides.length;i++){
            this.slides[i].setStyle('left','390px');
        	  this.slides[i].setStyle('top','45px');
          	this.slides[i].setStyle('height','60px');
          	this.slides[i].setStyle('opacity','0');
          }
*/
          //-1
          this.effectspos[this.slides.length-1].start('40px');    
          this.effects[this.slides.length-1].start('0.5');
          this.effectshg[this.slides.length-1].start('80px');
          this.effectstop[this.slides.length-1].start('25px');
          //-2
          this.effectspos[this.slides.length-2].start('0px');    
          this.effects[this.slides.length-2 ].start('0');
          this.effectshg[this.slides.length-2].start('60px');
          this.effectstop[this.slides.length-2].start('45px');
          //+1
          this.effectspos[1].start('355px');    
          this.effects[1].start('0.5');
          this.effectshg[1].start('80px');
          this.effectstop[1].start('25px');
          //+2
          this.effectspos[2].start('390px');    
          this.effects[2].start('0');
          this.effectshg[2].start('60px');
          this.effectstop[2].start('45px');
    
    }
    
    
		if(slide) {    
			if($chk(now) && now != iToShow){
			 this.slides[now].setStyle('z-index', '1');
			  //this.slides[now].setStyle('height','80px');
        this.effectshg[now].start('80px');
        this.effectstop[now].start('25px');
       // this.effectspos[now].start({left: '40px',top:'25px'});
				this.effectspos[now].start('40px');
        this.effects[now].start('0.5').chain(function(){
				//this.slides[now].setStyle('z-index', '200');
				//Da muss ich rein
				
        this.bigNext.setStyle('display', 'block');
        this.bigPrev.setStyle('display', 'block');
        
        	fadeIn.apply(this, [slide]);
          if (!this.options.hideText && this.options.addBarInside) {
            this.description.innerHTML  = this.descr[iToShow];
            this.title.innerHTML  = this.title[iToShow];
            if(this.options.browser) this.browserArr[this.now].addClass("rgsact");
          }
				}.bind(this));
			} else {
        fadeIn.apply(this, [slide]);
          if (!this.options.hideText && this.options.addBarInside) {
  		      this.description.innerHTML  = this.descr[iToShow];
            this.title.innerHTML  = this.title[iToShow];
            if(this.options.browser) this.browserArr[0].addClass("rgsact");
          }
      }
      
			this.now = iToShow;
		}
	

	},
	showSlideBack: function(iToShow){

		var now = this.now;		
		var currentSlide = this.slides[now];
		var slide = this.slides[iToShow];

		
		function fadeIn(s){
			s.setStyles({
				display:'block',
				visibility: 'visible',
				opacity: '1',
				left:'195px',
				height:'100px',
				top: '5px'
			});
			s.setStyle('z-index', '100');
			//this.effects[this.slides.indexOf(s)].start(1);
			//this.effectspos[this.slides.indexOf(s)].start('195px');
			this.fireEvent('onShow', [slide, iToShow]);
		};
    
    if (!this.options.hideText) {
      if (this.options.addBarInside) this.description.innerHTML = this.title.innerHTML = "&nbsp;";
      if(this.options.browser) {
        this.browserArr.each(function(el) {
          el.removeClass("rgsact");
        });
      }
    }
    
    
    if(now >= 0){
      switch(now)
      {
      case 0:
          //-1
          this.slides[this.slides.length-1].setStyle('z-index', '100');
          this.effectspos[this.slides.length-1].start('195px');    
          this.effects[this.slides.length-1 ].start('1');
          this.effectshg[this.slides.length-1].start('100px');
          this.effectstop[this.slides.length-1].start('5px'); 
          //-2
          this.effectspos[this.slides.length-2 ].start('40px');
          this.effects[this.slides.length-2].start('0.3');
          this.effectshg[this.slides.length-2].start('80px');
          this.effectstop[this.slides.length-2].start('25px'); 
          //-3          
          this.effectspos[this.slides.length-3].start('0px');    
          this.effects[this.slides.length-3].start('0');
          this.effectshg[this.slides.length-3].start('60px');
          this.effectstop[this.slides.length-3].start('45px'); 
          //+1
          this.effectspos[1].start('390px');
          this.effects[1].start('0');
          this.effectshg[1].start('60px');
          this.effectstop[1].start('45px');   
          //+2
          this.effectspos[2].start('0px');
          this.effects[2].start('0');  
        break;
      case 1:
          //-1
          this.slides[0].setStyle('z-index', '100');
          this.effectspos[0].start('195px');    
          this.effects[0].start('1');
          this.effectshg[0].start('100px');
          this.effectstop[0].start('5px'); 
          //-2
          this.effectspos[this.slides.length-1].start('40px');    
          this.effects[this.slides.length-1 ].start('0.3');
          this.effectshg[this.slides.length-1].start('80px');
          this.effectstop[this.slides.length-1].start('25px'); 
          //-3          
          this.effectspos[this.slides.length-2].start('0px');    
          this.effects[this.slides.length-2].start('0');
          this.effectshg[this.slides.length-2].start('60px');
          this.effectstop[this.slides.length-2].start('45px'); 
          //+1
          this.effectspos[2].start('390px');    
          this.effects[2].start('0');
          this.effectshg[2].start('60px');
          this.effectstop[2].start('45px'); 
          //+2
          this.effectspos[3].start('0px');    
          this.effects[3].start('0');          
        break;
         case 2:
          //-1
          this.slides[1].setStyle('z-index', '100');
          this.effectspos[1].start('195px');    
          this.effects[1].start('1');
          this.effectshg[1].start('100px');
          this.effectstop[1].start('5px'); 
          //-2
          this.effectspos[0].start('40px');    
          this.effects[0 ].start('0.3');
          this.effectshg[0].start('80px');
          this.effectstop[0].start('25px'); 
          //-3          
          this.effectspos[this.slides.length-1].start('0px');    
          this.effects[this.slides.length-1].start('0');
          this.effectshg[this.slides.length-1].start('60px');
          this.effectstop[this.slides.length-1].start('45px'); 
          //+1
          this.effectspos[3].start('390px');    
          this.effects[3].start('0');
          this.effectshg[3].start('60px');
          this.effectstop[3].start('45px'); 
          //+2
          this.effectspos[4].start('0px');    
          this.effects[4].start('0');          
        break;
      case (this.slides.length-2) :
          //-1
          this.slides[this.slides.length-3].setStyle('z-index', '100');
          this.effectspos[this.slides.length-3].start('195px');    
          this.effects[this.slides.length-3].start('1');
          this.effectshg[this.slides.length-3].start('100px');
          this.effectstop[this.slides.length-3].start('5px'); 
          //-2
          this.effectspos[this.slides.length-4].start('40px');    
          this.effects[this.slides.length-4 ].start('0.3');
          this.effectshg[this.slides.length-4].start('80px');
          this.effectstop[this.slides.length-4].start('25px'); 
           //-3          
          this.effectspos[this.slides.length-5].start('0px');    
          this.effects[this.slides.length-5].start('0');
          this.effectshg[this.slides.length-5].start('60px');
          this.effectstop[this.slides.length-5].start('45px'); 
          //+1
          this.effectspos[this.slides.length-1].start('390px');    
          this.effects[this.slides.length-1].start('0');
          this.effectshg[this.slides.length-1].start('60px');
          this.effectstop[this.slides.length-1].start('45px'); 
          //+2
          this.effectspos[0].start('0px');    
          this.effects[0].start('0');
        break;
      case (this.slides.length-1):
          //-1
          this.slides[this.slides.length-2].setStyle('z-index', '100');
          this.effectspos[this.slides.length-2].start('195px');    
          this.effects[this.slides.length-2].start('1');
          this.effectshg[this.slides.length-2].start('100px');
          this.effectstop[this.slides.length-2].start('5px'); 
          //-2
          this.effectspos[this.slides.length-3].start('40px');
          this.effects[this.slides.length-3].start('0.3');
          this.effectshg[this.slides.length-3].start('80px');
          this.effectstop[this.slides.length-3].start('25px'); 
           //-3          
          this.effectspos[this.slides.length-4].start('0px');    
          this.effects[this.slides.length-4].start('0');
          this.effectshg[this.slides.length-4].start('60px');
          this.effectstop[this.slides.length-4].start('45px'); 
          //+1
          this.effectspos[0].start('390px');
          this.effects[0].start('0');  
          this.effectshg[0].start('60px');
          this.effectstop[0].start('45px'); 
          //+2
          this.effectspos[1 ].start('0px');
          this.effects[1].start('0');  
        break;    
      default:
      
          
          //-1
          this.slides[now-1].setStyle('z-index', '100');
          this.effectspos[now-1].start('195px');    
          this.effects[now-1].start('1');
          this.effectshg[now-1].start('100px');
          this.effectstop[now-1].start('5px'); 
          //-2
          this.effectspos[now-2 ].start('40px');
          this.effects[now-2].start('0.3');
          this.effectshg[now-2].start('80px');
          this.effectstop[now-2].start('25px'); 
           //-3          
          this.effectspos[now-3].start('0px');    
          this.effects[now-3].start('0');
          this.effectshg[now-3].start('60px');
          this.effectstop[now-3].start('45px'); 
          //+1
          this.effectspos[now+1].start('390px');
          this.effects[now+1].start('0'); 
          this.effectshg[now+1].start('60px');
          this.effectstop[now+1].start('45px');  
          //+2
          this.effectspos[now+2 ].start('0px');
          this.effects[now+2].start('0');  
      }
    }
   
		if(slide) {    
			if($chk(now) && now != iToShow){
			  this.effectshg[now].start('80px');
        this.effectstop[now].start('25px');
			  this.slides[now].setStyle('z-index', '1');
			  this.effectspos[now].start('355px');
				this.effects[now].start('0.3').chain(function(){
				
        this.bigNext.setStyle('display', 'block');
        this.bigPrev.setStyle('display', 'block');
				
        	fadeIn.apply(this, [slide]);
          if (!this.options.hideText && this.options.addBarInside) {
            this.description.innerHTML  = this.descr[iToShow];
            this.title.innerHTML  = this.title[iToShow];
            if(this.options.browser) this.browserArr[this.now].addClass("rgsact");
          }
				}.bind(this));
			} else {
        fadeIn.apply(this, [slide]);
          if (!this.options.hideText && this.options.addBarInside) {
  		      this.description.innerHTML  = this.descr[iToShow];
            this.title.innerHTML  = this.title[iToShow];
            if(this.options.browser) this.browserArr[0].addClass("rgsact");
          }
      }
			this.now = iToShow;
		}
		

	}
	
});
SimpleSlideShowDemo.implement(new Options, new Events);
