$(document).ready(function() {
    $latest = $('div#latest-project');
    $latest.before('<div class="loading-box"><img src="/images/loading.gif"/><h3>loading portfolio...</h3></div>');
    $latest.animate({ left: -2000}, 0);
    $latest.css({visibility: 'visible'})
    $latest.wrapInner('<li class="project" id="fab"/>');
    $latest.empty().load('portfolio', function() {
      $latest.anythingSlider({
              easing: "easeOutBack",                // Anything other than "linear" or "swing" requires the easing plugin
              autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not
              startStopped: false,            // If autoPlay is on, this can force it to start stopped
              delay: 3000,                    // How long between slide transitions in AutoPlay mode
              animationTime: 1000,             // How long the slide transition takes
              hashTags: false,                 // Should links change the hashtag in the URL?
              buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
              pauseOnHover: false,             // If true, and autoPlay is enabled, the show will pause on hover
      });
      $('a.back', $latest).remove();
      $forward = $('a.forward');
      $forward.addClass('peruse').text('walk right');
      $forward.detach();
      $('#content').prepend($forward);
      var peruse = $('span.peruse').detach();
      $latest.after(peruse);
     
      var w = $(window).width();
      if (w > 900) {
        $latest.css({width: w});
        var l = (w - 900) / 2;
        $('#latest-project').animate({left: 0 - l}, 750);
        $('#projects').animate({left: l}, 750);
      }
      $(window).bind('resize', function() {
        var w = $(window).width();
        if (w > 900) {
          $latest.css({width: w});
          var l = (w - 900) / 2;
          $('#latest-project').animate({left: 0 - l}, 750);
          $('#projects').animate({left: l}, 750);
        }
      });
      $('div.loading-box').fadeOut();
      $('li#fab .project-visuals').colorbox({href:"/portfolio/fab", innerWidth: '816px', innerHeight: '530px', iframe:true, overlayClose:true});
      $('li#finkley .project-visuals').colorbox({href:"/portfolio/finkley", innerWidth: '816px', innerHeight: '530px', iframe:true, overlayClose:true});
      $('li#puma .project-visuals').colorbox({href:"/portfolio/puma", innerWidth: '816px', innerHeight: '530px', iframe:true, overlayClose:true});
    });
});
