


// init formationlinks on startpage to change the content by switching the preloaded formations
window.addEvent('domready', initStartpageFormations);
function initStartpageFormations() {
    if (Browser.Engine.trident && Browser.Engine.version < 5) {return;}
    if ($('startpage_formations')) {
        var contentObj = $$('#startpage_formations .content')[0];
        contentObj.set('morph', {'duration': 300});
        var closeContentObj = new Element('a', {'href': '#', 'html': 'x', 'class': 'close'}).inject(contentObj);
        closeContentObj.addEvent('click', function(e) {
            new Event(e).stop();
            contentObj.morph({'opacity': 0});
        });
        $$('#startpage_formations .formations a').each(function(formationLink) {
            formationLink.set('morph', {'duration': 300});
            if (formationLink.hasClass('active')) {
                formationLink.morph({'opacity': 0.5, 'color': '#000000'});
            }
            formationLink.addEvent('mouseenter', function() {
                if (!this.hasClass('active')) {
                    this.morph({'opacity': 0.9, 'color': '#dddddd'});
                }
            });
            formationLink.addEvent('mouseout', function() {
                if (!this.hasClass('active')) {
                    this.morph({'opacity': 1, 'color': '#ffffff'});
                }
            });
            if (!formationLink.hasClass('last')) {
                formationLink.addEvent('click', function(e) {
                    new Event(e).stop();
                    if (contentObj.getStyle('opacity') == 0 || contentObj.getStyle('display') == 'none') {
                        contentObj.setStyle('opacity', 0);
                        contentObj.setStyle('display', 'block');
                        contentObj.morph({'opacity': 1});
                    }
                    if (!this.hasClass('active')) {
                        $$('#startpage_formations .formations a').each(function(formationLink) {
                            if (formationLink.hasClass('active')) {
                                formationLink.removeClass('active');
                                formationLink.morph({'opacity': 1, 'color': '#ffffff'});
                            }
                        });
                        this.morph({'opacity': 0.5, 'color': '#000000'});
                        this.addClass('active');
                        $$('#startpage_formations .content .formation').each(function(formationContent) {
                            formationContent.removeClass('active');
                        });
                        $(this.rel).addClass('active');
                    }
                });
            }
        });
        $$('#startpage_formations .content  a').each(function(linkitem) {
            linkitem.set('morph', {'duration': 300});
            linkitem.addEvent('mouseenter', function() {
                this.morph({'color': '#ff0000'});
            });
            linkitem.addEvent('mouseleave', function() {
                this.morph({'color': '#999999'});
            });
        });
    }
}


// smooth effect on subfolderlist
window.addEvent('domready', initTeaser);
function initTeaser() {
    if (!startpage) {
        $$('#teaser').each(function(teaserObj) {
            teaserObj.set('morph', {'duration': 300});
            teaserObj.morph({'opacity': 0.3});
            teaserObj.addEvent('mouseenter', function() {
                this.morph({'opacity': 1});
            });
            teaserObj.addEvent('mouseleave', function() {
                this.morph({'opacity': 0.3});
            });
            
            $$('#teaser a').each(function(linkitem) {
                linkitem.set('morph', {'duration': 300});
                linkitem.addEvent('mouseenter', function() {
                    this.morph({'color': '#ff0000'});
                });
                linkitem.addEvent('mouseleave', function() {
                    this.morph({'color': '#999999'});
                });
            });
        });
    }
}


// navigation
window.addEvent('domready', initNavigation);
function initNavigation() {
    $$('#navigation a').each(function(linkitem) {
        linkitem.set('morph', {'duration': 300});
        linkitem.img = linkitem.getElement('img');
        linkitem.img.onmouseover = '';
        linkitem.img.onmouseout = '';
        linkitem.addEvent('mouseenter', function() {
            this.getParent().morph({'opacity': 0.5});
        });
        linkitem.addEvent('mouseleave', function() {
            this.getParent().morph({'opacity': 1});
        });
    });
    $$('#footer .nav a').each(function(linkitem) {
        linkitem.set('morph', {'duration': 300});
        linkitem.addEvent('mouseenter', function() {
            this.morph({'color': '#ff0000'});
        });
        linkitem.addEvent('mouseleave', function() {
            this.morph({'color': '#000000'});
        });
    });
}


// logo
window.addEvent('domready', initLogo);
function initLogo() {
    el = $('logo');
    el.set('morph', {'duration': 300});
    el.addEvent('mouseover', function() {
        this.morph({'opacity': 0.5});
    });
    el.addEvent('mouseout', function() {
        this.morph({'opacity': 1});
    });
}