/**
 *  Externe Links
 *  Anwendung:
 *      <a class="extern" href="http://www.example.com">extern</a>
 */
$$('a.extern,a.download_pdf').each(function(link){
    link.setProperty('target','_blank');
});

/**
 *  Popuplinks
 *  Anwendung:
 *      <a class="popup" href="http://www.example.com">In Popup öffnen</a>
 */
SqueezeBox.assign($$('a[class~=popup]'), {
    size: {x: 600, y: 400}
/*,
    ajaxOptions: {
        method: 'get'
    }
*/
});


/**
 *  Zoom für Bilder
 *  Anwendung:
 *      <a class="remooz" href="/bild.jpg" title="Bild Titel[ :: Bildbeschreibung]"><img src="/thumbnail.jpg" alt="bild" /></a>
 */
ReMooz.assign('.remooz', {
    'origin': 'img',
    //'shadow': 'onOpenEnd', // fx is faster because shadow appears after resize animation
    'shadow': 'onOpen', // fx is faster because shadow appears after resize animation
    'resizeFactor': 0.8, // resize to maximum 80% of screen size
    'cutOut': false, // don't hide the original
    'opacityResize': 0.4, // opaque resize
    'dragging': true, // disable dragging
    'centered': true // resize to center of the screen, not relative to the source element
});

var container = $('tab-container');
if (container !== null) {
    new SimpleTabs(container, {
        selector: 'h2'
    });
}

var accordions = document.getElements('dl.accordion]');
//if( $chk( document.id('startseite') ) ) {
if( accordions ) {
    accordions.each( function(accordion) {
        var cookiename = 'staedler-beck-'+ accordion.get('class').replace(/\s/g,'') + accordion.getChildren().length + accordion.getParent().get('class').replace(/\s/g,'');
        new Accordion( accordion, 'dt', 'dd', {
            display    : true,
            show       : Cookie.read(cookiename) | 0,
            alwaysHide : true,
            onActive   : function(toggler, section){
                toggler.setStyle('color', '#eee' );
                toggler.setStyle('background-color', '#333' );
                Cookie.write(cookiename, this.elements.indexOf(section), {
                    duration: 30
                });
            },
            onBackground : function(toggler, section){
                toggler.setStyle('color', '#333' );
                toggler.setStyle('background-color', '#e0e1e3' );
            }
            /*,
            onComplete: function(){
               console.log('fertig');
               console.log(arguments);
                //this.display.delay(1500, this, (this.previous + 1) % this.togglers.length);
            }*/
        });
    });
}

if( document.id('startseite-teaser-tabs') !== null ) {
    new SimpleMemoryTabs( document.id('startseite-teaser-tabs'), {
        selector: 'h3.toggler'
    });
}

