window.addEvent('domready', function(ev) {
    //this sets up sifr-elements in the content
    setupSifr();
	
    //this sets up sifr-elements in the sidebar
    var height = 0;
//    $$('.teaser .head p').each(function(hlEl) {
//        if(hlEl.hasClass('big'))
//        {
//            var addHeight = 5;
//
//            var elHeight = hlEl.getHeight().toInt();
//
//            if(elHeight > 32)
//            {
//                addHeight = 0;
//            }else if( elHeight > 16 )
//            {
//                addHeight = 10;
//            }
//
//            height = ( elHeight + addHeight );
//            hlEl.setStyle('margin-top', 0);
//        }
//        else
//        {
//            height = 17;
//        }
//        hlEl.setStyle('height', height + 'px');
//    })

    // fix problem with umlauts and length
    $$('.teaser .head p').each(function(el)
    {
        var txt = el.get("html");
        var newTxt = txt.replace(/&nbsp;/g, " ").trim();

        // fixes "text too wide" problem
        if(el.hasClass("big") && newTxt.length > 18)
        {
            var words = newTxt.split(" ");

            if(words.length > 1)
            {
                var breakat = Math.round( words.length / 2 ) - 1;

                words[breakat] = words[breakat] + "<br />";

                newTxt = words.join(" ").replace(/<br \/> /, "<br />");
            }
        }

        // fixes "german umlaut" problem
        newTxt = newTxt.replace(/([öäüß])/gi, '$1 ');
        el.set('html', newTxt);

        // fixes height problems
        if(el.hasClass('big'))
        {
            var addHeight = 5;

            var elHeight = el.getHeight().toInt();

            if(elHeight > 32)
            {
                addHeight = 0;
            }else if( elHeight > 16 )
            {
                addHeight = 10;
            }

            height = ( elHeight + addHeight );
            el.setStyle('margin-top', 0);
        }
        else
        {
            height = 17;
        }
        el.setStyle('height', height + 'px');
       
    })

    var font = "/media/flash/itc-franklin-gothic-conden-medium.swf";

    new MoosIFR('.teaser .head p', {
        flashsrc: font,
        textcolor: "#2D5E27",
        wmode : "transparent",
        flashvars : 'textalign=center'
    });
	
    $$('.teaser .sIFR-alternate').each(function(hlEl) {
        hlEl.setStyle('display', 'none');
    });
});