(function ($, undefined) {
  
  $(function () {
    $('footer').css('bottom', '-230px');
    
    $('footer h1 a').click(function () {
      var pos = 0;
      if (parseInt($('footer').css('bottom'), 10) !== 0) {
        pos = 0;
      } else {
        pos = -230;
      }
      
      $('footer')
        .animate({'bottom': pos + 'px'});
      return false;
    });
  });
  
  
  /* Referenzen
   * ---------------------------------------------------------------- */
  shuffle = function(o) {
    for (var j, x, i = o.length;
         i;
         j = parseInt(Math.random() * i, 10), x = o[--i], o[i] = o[j], o[j] = x) {}
    return o;
  };
  
  $(function () {
    $('#ref-icons li img')
      .hide()
      .css('z-index', 100)
      .hover(
        function () {
          $(this)
          .css('z-index', 110)
          .animate({
            width:  '160px',
            height: '160px',
            left:   '-20px',
            top:    '-20px'
          }, 'fast');
        },
        function () {
          $(this)
          .animate({
            width:  '120px',
            height: '120px',
            left:   '0px',
            top:    '0px'
          }, 'fast', function () {
            $(this).css('z-index', 100);
          });
        }
      )
      .closest('a')
        .click(function () {
          window.open($(this).attr('href'));
          return false;
        });
    
    $('#ref-icons').show();
    var i = 0;
    $.each(shuffle($('#ref-icons img').get()), function () {
      i++;
      var img = $(this);
      setTimeout(function () {
        img.fadeIn('slow');
      }, i*35);
    });
  });
  
})(jQuery);
