
//======================================================================

var debugModus		= 1; // Debugmodus EIN = 1 || AUS = 0
var firebugLight	= 0; // Firebug light EIN = 1 || AUS = 0

if(firebugLight)	{ document.write("<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>"); }

function debug(txt)
{
	if(!debugModus || typeof(console) != "object") { return; }
	else { console.log(txt); }
}
debug("debugModus = on");


//======================================================================
// scroller (videos)                                                    
//======================================================================

function teaserSlide(){

	//------------------------------------------------------------------
	
	var folio = $('folio');
	var teaserWidth = 237; //breite der teasers
	var thumbs = folio.getChildren('div');
	var totalLength = thumbs.length * teaserWidth;
	var teaserPerPage = 3;
	var btNext = $('next');
	var btPrev = $('prev');
	var actpos = 0;
	
	//------------------------------------------------------------------
	
	function set_slider() {
		check_arrows();

		folio.set('morph',{duration:1000,transition: Fx.Transitions.Sine.easeOut});

		btNext.onclick = function() {
			folio.morph({left:actpos - teaserWidth});
			actpos = actpos - teaserWidth;
			check_arrows();
		}

		btPrev.onclick = function() {
			folio.morph({left:actpos + teaserWidth});
			actpos = actpos + teaserWidth;
			check_arrows();
		}

		folio.style.left = (3*teaserWidth) + 'px';
		for( i=0;i<thumbs.length;i++ ) { thumbs[i].style.visibility = 'visible'; }
		folio.morph({left:0,onComplete:function(){
			folio.set('morph',{duration:250,transition: Fx.Transitions.Sine.easeInOut});
		}});
	}

	//------------------------------------------------------------------

	function check_arrows() {

		if(actpos == 0) {
			if(totalLength/teaserPerPage <= teaserWidth) {
				btPrev.style.visibility = 'hidden';
				btNext.style.visibility = 'hidden';
			} else {
				btPrev.style.visibility = 'hidden';
				btNext.style.visibility = 'visible';
			}
		} else if (actpos*-1 >= totalLength - (3*teaserWidth)) {
			btPrev.style.visibility = 'visible';
			btNext.style.visibility = 'hidden';
		} else {
			btPrev.style.visibility = 'visible';
			btNext.style.visibility = 'visible';
		}
	}

	//------------------------------------------------------------------

	set_slider();

	//------------------------------------------------------------------

}

//======================================================================
// domready
//======================================================================

window.addEvent('domready',function(){
	if($('folio')) { teaserSlide(); }
});
