$(document).ready(function() {

  $("#selectall").click(function() {
    var checked_status = this.checked;
    $(".item-select").each(function() {
      this.checked = checked_status;
    });
  });
  
  
  $("#action").change(function() {
    if ($("#action").val()=='delete' || !$("#action").val()) {
      //$("#withnotes").attr("disabled", true);
      //$("#addnotes").hide();
    } else {
      //$("#withnotes").attr("disabled", false);
      //$("#addnotes").show();
    }
  });
  
  $("#save").click(function() {
  
    if ($(":checkbox.item-select:checked").length < 1) {
      alert('You must select at least one item to continue.');
      return false;
    } 
    
    if (!$("#action").val()) {
      alert('You must select an action (below your selections) to continue.');
      $("#action").focus();
      return false;
    }
  
    if ($("#action").val()=='delete') {
      return confirm("You are about to delete the selected notes\n\nClick 'ok' to continue");
    }
  });
  
});
