// Begin Lazy Loading.
// 
// Lazy Loading allows us to load JS & CSS files only when the page requires them, saving bandwidth and decreasing load times.
// We get the option to inspect the mark-up and see if it's appropriate to include a particular plug-in or not automatically at runtime.
// For more detail on this technique, it's pros and cons, see: http://ajaxpatterns.org/On-Demand_Javascript#In_A_Blink
//
// NOTES:
// This file relies upon jQuery & the jquery.ondemand plugin. jQuery and the ondemand plugin MUST be included before this file.

$(document).ready(function(){
  
  // every page will require the form labelize plugin
  $.requireJs('/assets/javascript/jquery.InputHelper.min.js');
  
  // TEST: if we want a fancybox images on our site
  if($("a.fancybox").length > 0) {
    $.requireJs('/assets/javascript/fancybox/jquery.fancybox-1.2.6.js');
    $.requireCss('/assets/javascript/fancybox/jquery.fancybox-1.2.6.css');
  }
  
  // Countdown timer
  if($(".countdown").length > 0){
    $.requireJs('/assets/javascript/jquery.countdown.pack.js');
  }
  
  // we always need the flexslider because it's in the header
  $.requireJs('/assets/javascript/flexslider/jquery.flexslider.js');
  $.requireCss('/assets/javascript/FlexSlider-1.8/flexslider.css');

  // we always want to load progressive enhancements at the end of the load queue
  $.requireJs('/assets/javascript/progressive-enhancement.js');
  
});
