old_contents: $(document).ready(function(){
    $('input#order_use_billing').click(function() {
      show_billing(!$(this).is(':checked'));
    });
  
    $('#guest_checkout_true').change(function() {
      $('#customer_search').val("");
      $('#user_id').val("");
      $('#checkout_email').val("");
      $('#guest_checkout_false').prop("disabled", true);
  
      var fields = ["firstname", "lastname", "company", "address1", "address2",
                "city", "zipcode", "state_id", "country_id", "phone"]
      $.each(fields, function(i, field) {
        $('#order_bill_address_attributes' + field).val("");
        $('#order_ship_address_attributes' + field).val("");
      })
    });
  
    var show_billing = function(show) {
      if(show) {
        $('#shipping').show();
        $('#shipping input').prop("disabled", false);
        $('#shipping select').prop("disabled", false);
      } else {
        $('#shipping').hide();
        $('#shipping input').prop("disabled", true);
        $('#shipping select').prop("disabled", true);
      }
    }
  
  });
  
  
  
new_contents: $(document).ready(function(){
    var show_billing = function(show) {
      if(show) {
        $('#shipping').show();
        $('#shipping input').prop("disabled", false);
        $('#shipping select').prop("disabled", false);
      } else {
        $('#shipping').hide();
        $('#shipping input').prop("disabled", true);
        $('#shipping select').prop("disabled", true);
      }
    }
  
    $('input#order_use_billing').click(function() {
      show_billing(!$(this).is(':checked'));
    });
  
    $('#guest_checkout_true').change(function() {
      $('#customer_search').val("");
      $('#user_id').val("");
      $('#checkout_email').val("");
      $('#guest_checkout_false').prop("disabled", true);
  
      var fields = ["firstname", "lastname", "company", "address1", "address2",
                "city", "zipcode", "state_id", "country_id", "phone"]
      $.each(fields, function(i, field) {
        $('#order_bill_address_attributes' + field).val("");
        $('#order_ship_address_attributes' + field).val("");
      })
    });
  });
  
  
  
subject: Define show_billing function in checkouts/edit.js up top, before event binding that uses it