   history.replaceState(null,'',window.location.href.replace("#{location.hash}",hash_string))
   return params
 
-set_cookie = (key, value, expires_in) ->
+expires_in_to_date = (expires_in) ->
   cookie_expires = new Date
   cookie_expires.setTime(cookie_expires.getTime() + expires_in * 1000)
+  return cookie_expires
+
+set_cookie = (key, value, expires_in) ->
   cookie = "#{key}=#{value}; "
-  cookie += "expires=#{cookie_expires.toGMTString()}; "
+  cookie += "expires=#{expires_in_to_date(expires_in).toUTCString()}; "
   cookie += "path=#{window.location.pathname.substring(0,window.location.pathname.lastIndexOf('/')+1)}"
   document.cookie = cookie
 

  properties = $(collection).find('citeProperty')
  add_property_to_form(property,form) for property in properties

  submit_button = $('<input>').attr('type','button').attr('value','Submit').attr('class','btn btn-primary')
  submit_button.bind 'click', (event) =>
    submit_collection_form()
  save_button = $('<input>').attr('type','button').attr('value','Save').attr('class','btn')


  # set textareas to autosize
  $('textarea').autosize()

  # set an OAuth expiration callback
  if get_cookie 'access_token_expires_at'
    authorization_expires_in = parseInt(get_cookie('access_token_expires_at')) - Date.now()
    console.log "Disabling submit in #{authorization_expires_in}ms"
    setTimeout ->
      disable_submit()
    , authorization_expires_in

# set the author name using Google profile information
set_author_name = (callback) ->
