// Begin Lazy Loading. Lazy Loading allows us to load JS files and CSS only when the page requires them,
// saving bandwidth and decreasing load times.

$(document).ready(function(){
  // if we have a form on a page then we want to load some plugins
  if($("form")) {
    $.requireJs('/assets/scripts/yav.js'); // form validation library
    $.requireJs('/assets/scripts/jquery.yav.js'); // jQuery form validation
    $.requireJs('/assets/scripts/jquery.ui-1.0/ui.datepicker.js'); // graphical datepicker for date inputs
      $.requireCss('/assets/css/jQuery/ui.datepicker.css'); // CSS for the datepicker
  }
  
  // if we have a table on a page then we want to load the tablesorter plugin
  if($("table")) {
    $.requireJs('/assets/scripts/jquery.ui-1.0/ui.tablesorter.js'); // user sortable tables
      $.requireCss('/assets/css/jQuery/ui.tablesorter.css'); // CSS for tablesorter
  }
  
  // we always want to load progressive enhancements at the end of the load queue
  $.requireJs('/assets/scripts/progressive-enhancement.js');
});