 # ------------------------------
 
 disableOpenImageButton = (flag) ->
-  button = document.getElementById("open_button")
+  button = $("input#open_button")[0]
   button.disabled = flag
 
 this.openImage = ->
-  canvas = document.getElementById("diagram")
+  canvas = $('#diagram')[0]
   return unless canvas
   window.open(canvas.toDataURL("image/png"))
   return

  this.timerID = setTimeout("this.postRawText()", 1000)

this.postRawText = () ->
  disableOpenImageButton(true)
  data = "source_text=" + $("#source_text").val()
  $.ajax({
    type: "POST",
    url: "home/parse_text",
    data: data,
    success: (data) -> 
      fetchRestObjects("instances.json", instancesDidFetched)
    })

setInfoText = (text) ->
  $("label#info_label").text(text)

  message.from = _.find(instances, (obj) -> obj.id is message.from_id)

drawObjects = (instances, messages) ->
  canvas = $('#diagram')[0]
  return unless canvas
  if instances.length is 0
    canvas.wodth = 0
