$(function () {
  // init slider
  $('.slider').each(function (idx, slider) {
    // init infinite fading
    if ($('.slider-element', slider).length > 1) {
      (function fade() {
        $('.slider-element:last-child', slider).delay(4500).fadeOut(1500, function () {
          $(this).insertBefore($('> :first-child', slider)).show();
          fade();
        });
      }());
    }
  });
  
  // init store-fader
  /*
  $('.store-slider, .store-slider-slim').each(function (idx, slider) {
    var transition, autoTransition, thumbs = [], bigs = [];
      
    // collect images
    thumbs = $('li:eq(0)', this).addClass('thumbs').find('img');
    bigs = $('li:eq(1)', this).addClass('bigs').find('img');
    
    // transition function
    transition = function fade(idx) {
      var thumb = thumbs[idx], big = bigs[idx];
      
      // toggle active state
      $(thumbs).removeClass('active');
      $(thumb).addClass('active');
      
      // hide big
      $('.bigs :animated').stop(true, false);
      $(big).css({opacity: 0}).appendTo($('.bigs', slider)).animate({opacity: 1});
      
      clearTimeout(autoTransition);
      autoTransition = setTimeout(function () {
        transition(idx + 1 < thumbs.length ? idx + 1 : 0);
      }, 5000);
    };
    
    // activate thumbs
    $(thumbs).on('click', function (evt) {
      if (!$(this).is('.active')) {
        transition($(this).index());
      }
    });
    
    // show
    $(slider).show();
    transition(0);
  });
  */
});
