$(document).ready(function()
{
    if (window.location.hash) {
        var el = $(window.location.hash + '-content');
        el.remove();
        el.removeClass('secondary');
        $('.referenzen_slideshow #slideshow-container').prepend(el);
    }

    var el = $('#newsflash').parent('li');
    swfobject.embedSWF(
        '/images/stoerer_news.swf',
        'newsflash',
        '108',
        '34',
        '9.0.0',
        '/js/lib/expressInstall.swf',
        {
            lang:   el.hasClass('neues') ? 'de' : 'en',
            active: el.hasClass('active') ? 'true' : 'false'
        }
    );

    $('.home #slideshow-container').cycle({
        timeout: 6000,
        speed:   1000,
        pager:   '#home-index',
        pagerAnchorBuilder: function(index, el)
        {
            return $('#home-index li:nth-child(' + (index + 1) + ') a');
        },
        activePagerClass: 'active',
        pause: true
    });

    $('.home #slideshow-container').hover(function() {
        $('.home .overlay').fadeIn();
    }, function() {
        $('.home .overlay').fadeOut();
    });

    $('.referenzen_slideshow #slideshow-container').cycle({
        timeout: 5000,
        speed:   500,
        pause:   true,
        next:    'a.slideshow-next',
        prev:    'a.slideshow-prev'
    });

    $('ul#nav li.agentur > a').click(function()
    {
        $('ul#nav li.agentur').toggleClass('active');
    });

    $('div.textspalten.eins a.services-toggle').click(function()
    {
        $('div.textspalten.eins').fadeOut();
        $('div.textspalten.zwei').fadeIn();
        return false;
    });

    $('div.textspalten.zwei a.services-toggle').click(function()
    {
        $('div.textspalten.zwei').fadeOut();
        $('div.textspalten.eins').fadeIn();
        return false;
    });

    $('div.textspalten.eins a.news-toggle').click(function()
    {
        $('div.textspalten.eins').fadeOut();
        $('div.textspalten.zwei').fadeIn();
        return false;
    });

    $('div.textspalten.zwei a.news-toggle').click(function()
    {
        $('div.textspalten.zwei').fadeOut();
        $('div.textspalten.drei').fadeIn();
        return false;
    });

});

