   QUERIED_IDS = {
     'isbn': [],
     'oclc': [],
-    'lccn': []
+    'lccn': [],
+    'ht': [],
+    'ia': []
   }
 
 process_identifier = (identifier_string) ->

  ia_query(ia_id)

ia_query = (ia_id, level = 0) ->
  for table_id in HT_IA_TABLE_IDS
    fusion_tables_query "SELECT ht_identifier,score FROM #{table_id} WHERE ia_identifier = #{fusion_tables_escape(ia_id)}",
      (data) ->
        if data.rows?
          process_ht_id(row[0],(1 - level) * row[1]) for row in data.rows.reverse()
          if level == 0
            ht_query(row[0], 1) for row in data.rows.reverse()

ia_url = (ia_id) ->
  "https://archive.org/details/#{ia_id}"

  ht_query(ht_id)

ht_query = (ht_id, level = 0) ->
  if ht_id not in QUERIED_IDS['ht']
    QUERIED_IDS['ht'].push ht_id
    for table_id in HT_IA_TABLE_IDS
      fusion_tables_query "SELECT ia_identifier,score FROM #{table_id} WHERE ht_identifier = #{fusion_tables_escape(ht_id)}",
        (data) ->
          if data.rows?
            process_ia_id(row[0],(1 - level) * row[1]) for row in data.rows.reverse()
            if level == 0
              ia_query(row[0],1) for row in data.rows.reverse()

ht_url = (ht_id) ->
  "https://babel.hathitrust.org/cgi/pt?id=#{ht_id}"
