/* jQuery start */
$(document).ready(function(){
  
  $('body').addClass('js').removeClass('js-off');
  
  
  
  /* Work > Project > Slides */
  if ($().slides) {
    $('#slides').slides({
      autoHeight: true,
      autoHeightSpeed: 300,
      generateNextPrev: true,
      preload: true,
      slideSpeed: 300
    });
  }
  
  /* View.js */
  new View( $('a.zoom') );
  
  
  /* ================================ */
  /* Method > Process */
  
  lastBlock = $('#discover');
  maxWidth = 569;
  minWidth = 100;
  firstClick = 1;
  
  // route method nav clicks
  $('.process nav a').click(function(event) {
    
    // take HREF hash from 'nav a'
    // create selector from hash as ID
    navHash = $(this).context.hash;
    
    // fire click on '.process-steps li' matching ID
    $( navHash ).click();
    
    // don't follow link
    event.preventDefault();
  });
  
  // update method accordion
  $('.process .steps li').click(function(){
    newBlock = $(this);
    hiderBlock = lastBlock;
    
    // unset current nav step
    $('.process nav .current').removeClass('current');
    
    // set new current nav step
    navClass = newBlock.context.id;
    $('.process nav .' + navClass).addClass('current');
    
    // if clicked block is not current block
    if ( newBlock.hasClass('current') === false ) {
      lastBlock
        .addClass('hider')  // hide paragraph
        .animate({ width: minWidth }, {
          queue: false,
          duration: 300,
          easing: 'swing',
          complete: function(){  // after lastBlock collapse finishes
            hiderBlock.removeClass('hider');
            $(this).removeClass('preset current');
            
            // expand newBlock
            newBlock
              .addClass('preset')  // preset colors before animating
              .animate({ width: maxWidth }, {
                queue: false,
                duration: 300,
                easing: 'swing',
                complete: function(){
                  $(this).addClass('current');
                }
              });
          }
        });
        
      // assigned immediately after collapse starts
      lastBlock = $(this);
    }
  });
  
  
  /* Blog > Comment Rules */
  $('#show-rules').click(function(event){
    event.preventDefault();  // don't follow link
    $('#comment-rules').toggle();
  });
  
  
});

