$(document).ready(function() {
  // hide all empty subjects items, leaving one free
  var foundEmpty = false;
  $('#subjects ol li').each( function() {
    if (foundEmpty) {
      $(this).hide();
    } else if ($(this).find('select').val() == '') {
      foundEmpty = true;
    }
  });

  // when a select change makes a subject complete, unhide next subject
  $('#subjects ol li select').change( function() {
    var unselected = $(this).parents('li').find('select[value=""]');
    if (unselected.length == 0) {
      $($('#subjects ol li:has(select[value=""])')[0]).fadeIn();
    }
  });
});

