document.observe('dom:loaded', function(){
    function toggleStartShop() {

        if ($$('.start-shop').find(function(currentEl) {
            return currentEl.visible();
        }).next('.start-shop')) {
            $$('.start-shop').find(function(currentEl) {
                return currentEl.visible();
            }).hide().next('.start-shop').show();
        } else {
            $$('.start-shop').last().hide();
            $$('.start-shop').first().show();
        }

    //startSlide();
    }

    function cooleFunktion() {
        var currentShop = $$('.start-shop').find(function(currentEl) {
            return currentEl.visible();
        });
        var lis = currentShop.select('li');

        var currentLi = lis.find(function(e){
            return e.visible();
        });

        Effect.Fade(currentLi);
        //currentLi.hide();
        
        var x = currentLi.next('li');
        if(x) {
            //x.show();
            Effect.Appear(x);
        } else {
            //lis.first().show();
            Effect.Appear(lis.first());

        }
        //setTimeout(cooleFunktion(), 3000);
    }

    function arrayShuffle(){
      var tmp, rand;
      for(var i =0; i < this.length; i++){
        rand = Math.floor(Math.random() * this.length);
        tmp = this[i];
        this[i] = this[rand];
        this[rand] =tmp;
      }
    }

    Array.prototype.shuffle = arrayShuffle;

    //$$('.start-shop').first().show();
    // get the start shops

    var shops = $$('.start-shop');
    shops.shuffle();
    shops.first().show();
    //startSlide();
    //cooleFunktion();

    new PeriodicalExecuter(function(pe) {
        //console.log('executes 1 now' + new Date());
        toggleStartShop();
    }, 15);


    new PeriodicalExecuter(function(pe) {
        //console.log('executes 2 now' + new Date());
        cooleFunktion();
    }, 5 + 1.85);
});

