   else
     showFrame.src = url
 
+# initialize the page, so we are ready to render new pages fast
 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

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


  local:
    showFactlink: (id, successFn) ->
      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) ->
      url = "/facts/new" +
              "?fact=" + encodeURIComponent(text) +
              "&url=" + encodeURIComponent(siteUrl) +
              "&title=" + encodeURIComponent(siteTitle) +
              "&guided=" + encodeURIComponent(guided)
      showUrl url, successFn

      onFactlinkCreated = (e, id) ->
        remote.highlightNewFactlink text, id

