(function ($) {
  $(document).ready(function() {
    
    init();
    
    
    function init() {
      if (1100 > $(window).height()) {
        $('body').css({overflowY:'scroll'});
      }
      
      $('#header, #footer, #hello-robot, .view-work, #top-bar, #site-slogan, #navigation').hide();

      var offset = ($(window).height() / 2) - 150;
      
      if ($.browser.mozilla) {
        offset = 0;
      }

      $('#header').css({backgroundPosition: '0px 40px'});
      $('html').css({backgroundPositionY: offset+'px'});
      $('#page').css({paddingTop: offset+'px'});
      
      fadeInHeader();
    }
    
    function fadeInHeader() {
      $('#header').fadeIn(2000);
      setTimeout(moveHeaderToTop, 1000);
      
    }
    
    function moveHeaderToTop() {
      var duration = 2500;
      
      $('#page').animate({paddingTop:'0'}, {duration: duration, easing: 'easeInOutExpo', complete: fadeInTopBar});
      $('html').animate({backgroundPositionY: '0px'}, {duration: duration, easing: 'easeInOutExpo'});
      

    }
    
    function fadeInTopBar() {
      $('#top-bar').fadeIn(500, fadeInNavigation);
      $('#header').css({backgroundPosition: '0 30px'});
    }
    
    function fadeInNavigation() {
      $('#site-slogan, #navigation').fadeIn(500);
      setTimeout(showWork, 500);
    }
    
    function showWork() {

      $('.view-work div.work').hide();
      $('.view-work').show();
      var stagger = 150;
      var count = 0;
      $('.view-work div.work').each(function() {
        $(this).delay(count*stagger).fadeIn(stagger);
        count++;
      });
      
      //setTimeout(moveHeaderToTop, 300);
      setTimeout(fadeInFooter, count*stagger);
    }
    
    function fadeInFooter() {
      var offset = $('#footer').offset();
      //$('#footer').css({top: ($(window).height() + $('#footer').height())+'px'}).show().animate({top:offset.top+'px'}, cleanup);
      $('#footer').fadeIn(showHelloRobot);
      
    }
    
    function showHelloRobot() {
      $('#hello-robot').css({top: '-330px'}).show().animate({top: '-70px'}, {duration: 2500, easing: 'easeInOutExpo', complete: cleanup});
    }
    
    function cleanup() {
      $('body').css({overflow:'auto'});
    }
  });
})(jQuery);
;
(function ($) {
  $(document).ready(function() {
    $('a.info').css({
      opacity: 0.8
    });
    $('div.work').hover(function() {
      $(this).find('a.info').css('display', 'none').fadeIn('fast');
    },
    function() {
      $(this).find('a.info').css('display', 'block').fadeOut(300);
    });
  });
})(jQuery);
;

