var slideShow = {
    run : function() {
        
        if ($('#banner a').length > 1) {
        
            $('#banner').cycle({
                fx : 'fade',
                speed : 1500,
                timeout : 6000,
                pause : true,
                pager : '#nav',
                pagerEvent: 'mouseover',
                pagerAnchorBuilder : function(idx, slide) {
                    return '#nav a:eq(' + idx + ')';
                }
            });
        }
    }
};

$(document).ready(function() {

    // make slider links visible
    $('#newHighlightsNext').show();
    $('#newHighlightsPrev').show();

    // offer of the month
    if ($('#currentOfferArticles').length > 0) {
        $('#currentOfferArticles').cycle({
            fx : 'scrollHorz',
            speed : 600,
            pause: true,
            timeout : 6000,
            next : '#newHighlightsNext',
            prev : '#newHighlightsPrev'
        });
    }

    // start specialPriceHighlights
    slideShow.run();

    // fill newsletter field with default value
    $('.newsletterInput').toggleValue('Ihre E-Mailadresse');

    // add popup to paypal-logo
    $('div.paypal a').click(function() {
        window
            .open(
                'https://www.paypal.com/de/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside',
                'olcwhatispaypal',
                'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=500, height=500');
        return false;
    });

    // special shops
    $('a#show-all-special-shops').click(function() {

        $('div#SpecialShopsLinkBox').css({
            'z-index' : 200
        });
        
        $('div#SpecialShopsLinkBox').load('/xhr/index/specialshops.php',
            function(responseText, textStatus, XMLHttpRequest) {
                if (textStatus == 'success') {
                    $('a#Close-SpecialShopsLinkBox').click(function() {
                        $('div#SpecialShopsLinkBox:visible').hide();
                    });
                }
            }
        );

        $('div#SpecialShopsLinkBox:hidden').show();

    });
});