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

  while(window.historyCache.length > 0)
    cache = window.historyCache.pop()
    if cache.url == url
      replaceHTML cache.html
      triggerPageChange
      return

  fetchReplacement url

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

reflectNewUrl = (url) ->

  else
    createDocumentUsingWrite

replaceHTML = (html) ->
  doc = createDocument html
  title = doc.querySelector "title"
  replaceDocument doc.body,title?.textContent, 'cache'


replaceDocument = (body,title,cache) ->
  originalBody = document.body
  document.documentElement.appendChild body.cloneNode(true), originalBody
  document.documentElement.removeChild originalBody
  document.title = title
  window.historyCache.push({url: document.location.href, title:title,body:body}) if cache


extractLink = (event) ->
