function TeaserManager(options) {
	this.aTeaser = options.aTeaser;
	this.oSwitch = options.oSwitch;
	this.oView = options.oView;
	this.oWindow = options.oWindow;
	this.oButton = options.oButton;
	this.iTeaserWidth = 150;
	this.iTeaserHeight = 150;
	this.iTeaserSpacing = 10;
	this.iTeaserMarginRight = 30;
	this.iTeaserMarginTop = 151;
	this.bTeaserSlide = false;
	this.iMode = 0; //0=fixed, 1=flex
	this.iTeaserLeftSafety = options.iTeaserLeftSafety;
	this.aPositions = options.aPositions;
	this.aPosition = this.aPositions[0];
	
	if (typeof TeaserManager._initialized == "undefined") {
		
		TeaserManager.prototype.initialize = function() {
			var oTempThis = this; 
			Event.observe(this.oButton.anchor, 'click', function() { oTempThis.toggleMode.call(oTempThis) }, false);
			Event.observe(this.oWindow, 'resize', function() { oTempThis.positionTeaser.call(oTempThis) }, false);
			/*aTeaser.each( function(t1) { $A(t1.getElementsByTagName("h1")).each( function(oTeaser) { 
				oTeaser.onclick = function() { oTempThis.toggleMode.call(oTempThis); } ; 
				oTeaser.style.cursor = 'pointer' ; 
			} ) } );*/
			this.positionTeaser();
			this.bTeaserSlide = true;
			this.showTeaser();
			TeaserManager._initialized = true;
		}
		
		TeaserManager.prototype.getPositionLimit = function() {
			if (this.iMode == 0) { //fixed
				return 0;
			} else {
				return this.aPositions.length-1;
			}
		}
		TeaserManager.prototype.getTeaserLeftSafety = function() {
			if (this.iMode == 0) { //fixed
				return 50;
			} else {
				return this.iTeaserLeftSafety;
			}
		}
		
		TeaserManager.prototype.setMode = function(mode) {
			this.iMode = mode;
			this.oButton.setMode(mode);
			//$('teaserNavigationHint').innerHTML = (mode == "1") ? "MAXIMIEREN I&nbsp;" : "MINIMIEREN I&nbsp;";
			this.positionTeaser();
		}
		
		TeaserManager.prototype.toggleMode = function() {
			this.setMode( (this.iMode == 0) ? 1 : 0 );
		}
		
		TeaserManager.prototype.getLeft = function(pos) {
			return ( this.iTeaserWidth*(pos-1) + this.iTeaserSpacing*(pos-1) );
		}
		
		TeaserManager.prototype.getTop = function(pos)
		{
			return ( this.iTeaserHeight*(pos-1) + this.iTeaserSpacing*(pos-1) );
		}
		
		TeaserManager.prototype.getTeaserCoordinates = function(aPosition) {
			var aCoords = new Array;
			for (var i = 0; i < this.aTeaser.length; i++) {
				aCoords.push( { x:this.getLeft(aPosition[i][0]), y:this.getTop(aPosition[i][1]) });
			}
			return aCoords;
		}

		TeaserManager.prototype.getTeaserDimensions = function(aPosition) {
			var iWidth = 0;
			var iHeight = 0;
			for (var i = 0; i < this.aTeaser.length; i++) {
				if ( iWidth  < this.getLeft(aPosition[i][0]) + this.iTeaserWidth  ) iWidth  = this.getLeft(aPosition[i][0]) + this.iTeaserWidth;
				if ( iHeight < this.getTop(aPosition[i][1])  + this.iTeaserHeight ) iHeight = this.getTop(aPosition[i][1])  + this.iTeaserHeight;
			}
			return { width:iWidth, height:iHeight };
		}
		
		TeaserManager.prototype.positionTeaser = function() {
			var left = 0;
			var i = -1;
			do {
				i++;
				oDimensions = this.getTeaserDimensions(this.aPositions[i]);
				if ((this.oView.getDimensions().width - this.getTeaserLeftSafety() - oDimensions.width - this.iTeaserMarginRight) < 0) {
					left = this.getTeaserLeftSafety();
				} else {
					left = this.oView.getDimensions().width - oDimensions.width - this.iTeaserMarginRight;
				}
			}
			while (i < this.getPositionLimit() && ((this.oView.getDimensions().width - this.getTeaserLeftSafety() - oDimensions.width - this.iTeaserMarginRight) < 0))
			
			//$('teaserNavigationHint').innerHTML = (this.iMode == 1 || left < this.iTeaserLeftSafety) ? "block" : "none" ;
			// || 
			this.oSwitch.style.display = (left < this.iTeaserLeftSafety || ( (i!=0) && this.iMode == 1 ) )  ? "block" : "none" ;
			
			aCoords = this.getTeaserCoordinates(this.aPositions[i]);
			for (var i = 0; i < this.aTeaser.length; i++) {
				if (this.bTeaserSlide) {
					new Effect.Move( this.aTeaser[i], { y:aCoords[i].y+this.iTeaserMarginTop, x:aCoords[i].x+left, mode:'absolute', duration:0.2 } );
				} else {
					this.aTeaser[i].style.left = (aCoords[i].x+left) + "px";
					this.aTeaser[i].style.top  = (aCoords[i].y+this.iTeaserMarginTop)  + "px";
				}
			}
			if (this.bTeaserSlide) {
				new Effect.Move( this.oSwitch, { y:this.iTeaserMarginTop-50, x:left+oDimensions.width-this.oSwitch.getDimensions().width, mode:'absolute', duration:0.2 } );
			} else {
				this.oSwitch.style.left = (left+oDimensions.width-this.oSwitch.getDimensions().width) + "px";
				this.oSwitch.style.top  = (this.iTeaserMarginTop-50)  + "px";
			}
		}

		TeaserManager.prototype.showTeaser = function() {
			for (var i = 0; i < this.aTeaser.length; i++) {
				new Effect.Appear( this.aTeaser[i], { duration : 1, queue:{scope:'myscope'+i, position:'end'} } );
			}	
		}		
		
		TeaserManager.prototype.hideTeaser = function() {
			for (var i = 0; i < this.aTeaser.length; i++) {
				new Effect.Fade( this.aTeaser[i], { duration : 0.5, queue:{scope:'myscope'+i, position:'end'} } );
			}	
		}	
		
	}
	
	this.initialize();	
}







