$(function() {
  $('.services li').children('a').mouseover(function() {
    // Yeah, we have to do this liiiiittle part with Javascript
    $(this).css('z-index', '1000').parent().siblings().children('a').css('z-index', '999');
  });
  $('.screenshot').each(function() {
    var $this = $(this);
    var $img = $this.find('img')
    var pos = 0;
    var duration = 1000
    var step = 10000
    $img.eq(0).show().siblings().hide();
    function next() {
      var $visible = $img.filter(':visible')
      var $next = $visible.next()
      if ( !$next.length ) {
        $next = $img.eq(0)
      }
      $next.css('opacity', 0).show().animate({
        opacity: 1
      },{
        duration: duration,
        complete : function() {
          setTimeout(function() {
            next();
          }, step)
        }
      })
      $visible.animate({
        opacity: 0
      },{
        duration: duration,
        complete : function() {
          $(this).hide().css('opacity', 1)
        }
      })
    }
    setTimeout(function() {
      next();
    }, step)
  });
})

