// DOM ready
$(document).ready(function(){

  $('.nav-menu').onePageNav();

  $('.nav-menu').mobileMenu();

  // Clone applications to get a second collection
  var $data = $(".portfolio-lists").clone();
  
  //NOTE: Only filter on the main portfolio page, not on the subcategory pages
  $('.portfolio-sort li a').click(function(e) {
    $(".portfolio-sort li a").removeClass("active"); 
    // Use the last category class as the category to filter by. This means that multiple categories are not supported (yet)
    var filterClass = $(this).attr('class').split(' ').slice(-1)[0];

    if (filterClass == 'all') {
      var $filteredData = $data.find('.portfolio-item');
    } else {
      var $filteredData = $data.find('.portfolio-item[data-type=' + filterClass + ']');
    }
    $(".portfolio-lists").quicksand($filteredData, {
      duration: 800,
      easing: 'swing',
    });   
    
    $(this).addClass("active");       
    return false;
  });
});

$(window).load(function() {
  $('.flexslider').flexslider({
    animation: "slide",
    smoothHeight: true,
    keyboard:false,
    controlNav:false
  });
});