	/*
	 *    TabSlideShow 1.0
	 *    written by Profartis Design Kft.
	 */
		
	var SlideTabs;
	var TabSlideShow = function(options)
	{
			
		this.active = 0;
		this.counter = 0;
		this.executer = null;
		this.elements = options.elements;
		this.contents = options.contents;
		this.step = options.step ? options.step : 10;						
		
		this.play = function(t)
		{
			this.counter = $$(this.elements).length-2;
			this.executer = new PeriodicalExecuter(this.next.bind(this), this.step);						
			$$(this.elements+'.controls .play')[0].hide();
			$$(this.elements+'.controls .pause')[0].show();
		}						
		
		this.pause = function()
		{				
			this.executer.stop();
			$$(this.elements + '.controls .pause')[0].hide();
			$$(this.elements + '.controls .play')[0].show();	
		}
			
		this.next = function(manual)
		{				
			if(manual=='m' && this.executer){ this.pause(); }
			this.active = (this.active != this.counter) ? this.active+1 : 0;				
			this.doIt();
		}
			
		this.prev = function(manual)
		{
			if(manual=='m' && this.executer){ this.pause(); }
			this.active = (this.active != 0) ? this.active-1 : this.counter;
			this.pause();
			this.doIt();
		}
			
		this.jump = function(nr)
		{
			this.active = nr;
			if(this.executer){ this.pause(); }			
			this.doIt();
		}
			
		this.doIt = function()
		{						
			// Change tab
			$$(this.elements+' a').invoke('removeClassName','active-tab');
			$$(this.elements+' a')[this.active].addClassName('active-tab');
			
			// Change content
			$$(this.contents).invoke('hide');
			if ($$(this.contents)[this.active]) {
				$$(this.contents)[this.active].setStyle({ display: 'block' });
			}
	
		}
			
		// Auto start 
		if(options.autoplay){ this.play(); }
			
		// onClick events			
		$$(this.elements).each(function(e,i){
			if (!e.hasClassName('controls')) {
				e.observe('click', function(){ this.jump(i); }.bind(this));
			}
		}.bind(this));
			
	}
