 
   local:
     showFactlink: (id, successFn) ->
-      successCalled = 0
-      onLoadSuccess = ->
-        unless successCalled
-          successCalled++
-          successFn()
-
-      showFrame.onload = onLoadSuccess
-      # Somehow only lower case letters seem to work for those events --mark
-      $(document).bind "modalready", onLoadSuccess
-      loadUrl "/facts/" + id
-      showFrame.className = "overlay"
+      url = "/facts/" + id
+      showUrl url, successFn
       return # don't return anything unless you have a callback on the other site of easyXdm
 
     prepareNewFactlink: (text, siteUrl, siteTitle, guided, successFn, errorFn) ->
-      successCalled = 0
-      onLoadSuccess = ->
-        unless successCalled
-          successCalled++
-          successFn()  if $.isFunction(successFn)
+      url = "/facts/new" +
+              "?fact=" + encodeURIComponent(text) +
+              "&url=" + encodeURIComponent(siteUrl) +
+              "&title=" + encodeURIComponent(siteTitle) +
+              "&guided=" + encodeURIComponent(guided)
+      showUrl url, successFn
 
-      showFrame.onload = onLoadSuccess
-      # Somehow only lower case letters seem to work for those events --mark
-      $(document).bind "modalready", onLoadSuccess
-      loadUrl "/facts/new" + "?fact=" + encodeURIComponent(text) + "&url=" + encodeURIComponent(siteUrl) + "&title=" + encodeURIComponent(siteTitle) + "&guided=" + encodeURIComponent(guided) + "&layout=client"
-      showFrame.className = "overlay"
       onFactlinkCreated = (e, id) ->
         remote.highlightNewFactlink text, id
 

  else
    showFrame.src = url

loadUrl '/facts/new'

$("iframe").preventScrollPropagation()

          showFrame.contentWindow.position top, left
      return # don't return anything unless you have a callback on the other site of easyXdm

showUrl = (url, successFn) ->
  successCalled = 0
  onLoadSuccess = ->
    unless successCalled
      successCalled++
      successFn()  if $.isFunction(successFn)

  showFrame.onload = onLoadSuccess
  # Somehow only lower case letters seem to work for those events --mark
  $(document).bind "modalready", onLoadSuccess
  loadUrl url
  showFrame.className = "overlay"

loadUrl = (url)->
  history = showFrame.contentWindow.Backbone?.history
  if history?
