 window.historyCache = []
+window.testArray = []
 visit = (url) ->
   if browserSupportsPushState?
     reflectNewUrl url

  else
    createDocumentUsingWrite

replaceHTML = (html,cache) ->
  doc = createDocument html
  originalBody = document.body
  document.documentElement.appendChild doc.body, originalBody
  document.documentElement.removeChild originalBody
  document.title = title.textContent if title = doc.querySelector "title"
  window.historyCache.push({url: document.location.href, html:html}) if cache


extractLink = (event) ->

  while(window.historyCache.length > 0)
    cache = window.historyCache.pop()
    if cache.url == url
      replaceDocument cache.body, cache.title
      triggerPageChange
      return

  fetchReplacement url

fullReplacement = (html, url) ->
  replaceHTML html
  triggerPageChange()

reflectNewUrl = (url) ->
