     else
       handle_file_step_two( chosen_file, template )
 
+Template.InsertImageDialog.destroyed = ->
+  window.image_upload_template = null
+
 Template.InsertImageDialog.created = ->
+  window.image_upload_template = this
+
   @selected_files = new ReactiveVar()
   @selected_files.set([])
 

      save_label: "Upload"
      render_complete: (parent_template) ->
        parent_template.$("#modal-dialog-save").on("click", (event) ->
          insert_image_save_func(parent_template,
               send_coll, my_id, "images")
        )


my_uploader = null # variable local to this script
uploader_state_changed = new Deps.Dependency
upload_progress_dialog = null

# global
window.image_upload_template = null

# ---- Template.binary_data_from_id_block -------------

