var slideShow = {
    run : function() {
        $('#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() {
    
    if ($('.currentOfferArticlesSlidePage').length > 3) {
        // make slider links visible
        $('#newHighlightsNext').show();
        $('#newHighlightsPrev').show();
    }

    // offer of the month
    $('#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('Adresse e-mail');

    // add popup to paypal-logo
    $('div.paypal a').click(function() {
        window
                .open(
                        'https://www.paypal.com/fr/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();

    });
});