function setTeaser() {
    
    var Elements = $('teaser-row').getElementsByClassName('content-element');
    Elements[0].className = 'content-element first';
    for (var x = 0; x <= Elements.length; x++) {
        if (Elements[x] != undefined ) {
            Elements[x].style.backgroundImage = "url("+getImage(Elements[x])+")";
            var teaser = new mts_start(Elements[x], 'fileadmin/templates/default/');
        }
    }
    
}

function getImage(element) {
    
    var images = element.getElementsByTagName('img');
    return images[0].src;
}


/**
 * Visualisation of teaser text elements on landing page
 */

var mts_start = Class.create ({

    initialize: function (element, template_path) 
    {
		this.getClient();
        this.teaser = element;
        this.teasertext = this.getTeaserText();
        this.template_path = template_path;

        if (this.teasertext) {
            this.teasertext.className = this.teasertext.className + ' selectedTeasertext';
            this.AppendOverlay();
            Element.hide(this.teasertext);
            this.setEvent();
        }
    }, 
	
	getClient: function()
	{
		this.client = "default";
		if (navigator.appName == "Microsoft Internet Explorer" ) {
			this.client = "IE";
		} 
	},
	
    /**
     * Append Overlay Image
     * 
     * @return void
     */
    AppendOverlay: function()
    {
        var pngImage = new Element ('img', { 'id' : this.teaser.id + 'overlay', 'src' : this.template_path + 'img/bg_teaser_selected.png' });
        pngImage.addClassName('teaser_overlay');
        this.highLightImage = pngImage;
        this.teaser.insert(pngImage);
        this.highLightImage.hide();
    },
    
    /**
     * get Teaser subtext element
     *
     * @return HTML_Element_object or false
     */
    getTeaserText: function()
    {
        var DIVElements = this.teaser.getElementsByTagName('div');
        for (key in DIVElements) {
            if (DIVElements[key].className == 'detailtext') {
                return DIVElements[key];
            }
        }
        return false;
    },
    
    /**
     * set event Listeners (on Click Event on teaser)
     *
     * @return void
     */
    setEvent: function()
    {
        Event.observe( this.teaser, "click", this.GoToLink.bind(this) ); 
        Event.observe( this.teaser, "mouseover", this.show.bind(this) ); 
        Event.observe( $('startcontent'), "mouseover", this.hideAllLayers.bind(this) ); 
        Event.observe( $('nav'), "mouseover", this.hideAllLayers.bind(this) ); 
    },
    
    /**
     * Toggle show/hide
     *
     */
    toggle: function()
    {
        if ( this.teasertext.visible() ) {
            this.hide();
        } else {
            this.show(); 
        } 
    },
    
    /**
     * Display Text in headerimage
     * 
     */
    show: function()
    {       
        Event.stopObserving(this.teaser, 'mouseover');
        this.teasertext.style.position = "absolute";
        this.teasertext.style.top = "-197px";
        
        var positionx = this.teaser.positionedOffset();

        if ( positionx[0] >= ( this.teaser.offsetWidth * 2 -2 ) ) {
            this.teasertext.style.left = this.teaser.offsetWidth * -1  +"px";
        } else {
            this.teasertext.style.left = '0';
        }

        this.teasertext.appear( { duration: 0.5 } );

		if (this.client == "IE") {
			Element.show(this.highLightImage);
		} else {	
        	this.highLightImage.appear( { duration: 0.5 } );
		}
        this.hideAllLayers();
    },
    
    hide: function()
    {
        //this.teasertext.hide();
		if (this.client == "IE") {
			this.highLightImage.hide();
		} else {
			this.highLightImage.fade( { duration: 0.5 } );
		}
        this.teasertext.fade( { duration: 0.5 } );  
        Event.observe( this.teaser, "mouseover", this.show.bind(this) ); 
    },
    
    /**
     * Hide all other Tooltips, that have been created before
     * 
     */
    hideAllLayers: function() 
    {
        var Elements = document.getElementsByClassName('detailtext');
        for (var x = 0; x <= Elements.length; x++) {
            if (Elements[x] != undefined ) {
                if (Elements[x].nodeName == 'DIV' && this.teasertext != Elements[x]) {
                    Elements[x].fade( { duration: 0.5 } );
                }
            }
        }
        
        var Elements = document.getElementsByClassName('teaser_overlay');
        for (var x = 0; x <= Elements.length; x++) {
            if (Elements[x] != undefined ) {
                if (Elements[x].nodeName == 'IMG' && this.highLightImage != Elements[x]) {
					if (this.client == "IE") {
                    	Elements[x].hide();
					} else {
						Elements[x].fade( { duration: 0.5 } );
					}
                }
            }
        }
        Event.observe( this.teaser, "mouseover", this.show.bind(this) ); 
    },
    
    /**
     * Navigate to first href found in teasertext
     */
    GoToLink: function()
    {
        var href = this.teaser.getElementsByTagName('h2');
       
        if (href.length > 0) {
             
            if (href[0].childNodes[0]) {
                if (href[0].childNodes[0].nodeName == 'A') {
                    href = href[0].childNodes[0].href;
                    document.location.href = href;
                }
            }
        }
        return;
    }
  
});