         console.log "Access Token Validation Error: #{textStatus}"
       success: (data) ->
         set_cookie('access_token',params['access_token'],params['expires_in'])
+        set_cookie('access_token_expires_at',expires_in_to_date(params['expires_in']).getTime(),params['expires_in'])
         $('#collection_select').change()
       complete: (jqXHR, textStatus) ->
         callback() if callback?

  cite_collection_editor_config = $.extend({}, default_cite_collection_editor_config, window.cite_collection_editor_config)
  google_oauth_parameters_for_fusion_tables['client_id'] = cite_collection_editor_config['google_client_id']
  
  if location.hash.substring(1).length
     console.log "Setting OAuth URL parameter state: #{location.hash.substring(1)}"
     google_oauth_parameters_for_fusion_tables['state'] = location.hash.substring(1)
  

  $('html, body').animate({scrollTop: $(document).height()-$(window).height()},600,'linear')

# save collection form values to localStorage
@save_collection_form = save_collection_form = ->
  collection = $('#collection_select').val()
  localStorage[collection] = true
  for child in $('#collection_form').children()
