--- linkFinder.js	2004-03-04 04:54:34.000000000 +0900
+++ linkFinder+ja.js.u8	2004-09-07 22:36:02.783000000 +0900
@@ -1,16 +1,45 @@
 const linkFinder = {
+
   // regular expressions for identifying link types
   // XXX some pages use << for first and < for prev, so we should handle things like that differently
-  re_first: /^first\b|\bfirst$|^begin|\|<|\u00ab/i, // ? >\u007c| ?
-  re_prev:  /^prev(ious)?\b|prev$|previous$|^back\b|\bback$|^<<?-?$|\u00ab/i, // \u003c / = | <=
-  re_next:  /^next\b|\bcontinue\b|next$|^-?>?>$|\u00bb$/i,
-  re_last:  /^last\b|\blast$|^end\b|>\|/i, // ? >\u007c| ?
+  re_top: /\btop\b|\bhome\b|\bcover\b|トップ|ホーム|[主首]頁|表紙|ｔｏｐ|ｈｏｍｅ/i,
+  re_up_2: /↑/,
+  re_first: /^first\b|\bfirst$|^begin\b|^start\b|最初|先頭|スタート/i, // ? >\u007c| ?
+  re_first_2: /\|<|\u00ab/,
+  re_prev:  /^prev(ious)?\b|prev$|previous$|^back\b|\bback$|まえへ/i, // \u003c / = | <=
+  re_prev_2: /前|旧|古い|過去|戻る|もどる|モドル|^<<?-?$|\u00ab|←|＜/,
+  re_next:  /^next\b|\bcontinue\b|\bnext$|\bforward$|つぎへ|ツギ|進む|つづ[きく]|\benter\b|本文/i,
+  re_next_2: /次|先|後|続|^-?>?>$|\u00bb$|→|＞|へ\b|^more\b|more$|詳(?:し[いく]|細)/,
+  re_last:  /^last\b|\blast$|^end\b|最[後終]/i, // ? >\u007c| ?
+  re_last_2: />\||最[新近]/,
+  re_contents: /\bcontents\b|\bmenu\b|\bsite[ -]?map\b|コンテンツ|目次|もくじ|モクジ|サイトマップ/i,
+  re_part: /\bpart\d*\b|第.+?部|パート/i,
+  re_chapter: /\bchapter\d*\b|第.+?章/i,
+  re_section: /\b(?:section|clause)\d*\b|§|第.+?節|セクション/i,
+  re_subsection: /\bsub(?:clause|section)\b/i,
+  re_appendix: /\bappendix\b|\bannex\b|付録|附録|付属書|附属書|おまけ|オマケ/i,
+  re_index: /\bindex\b|索引|インデックス|一覧/i,
+  re_glossary: /\bglossary\b|用語集/i,
+  re_copyright: /\bcopyright\b|著作権|コピーライト|\u00A9|\(c\)/i,
+  re_copyright_2: /\blicense\b|ライセンス|規約|\bprivacy\b|個人情報|プライバシ|免責/i,
+  re_help: /\b(?:help|faq|how ?to|q ?& ?a|support)\b|ヘルプ|サポート|案内|手引|使い方|よくある質問/i,
+  re_help_2: /について|紹介|はじめ[にて]|[始初]め[にて]|ようこそ|注意|留意|\b(?:about|info(?:rmation)?)\b|ルール|説明|アバウト|ガイドライン|[方指]針/i,
+  re_history_2: /\bhistory\b|履歴|更新/i,
+  re_search: /\bsearch\b|\bfind\b|\bseek\b|検\s*索|サーチ|探す/i,
+  re_news: /\b(?:news|topics?|what'?s ?new)\b|ニュース|お[し知]らせ|新着|最新情報|トピックス|\brss\b/i,
+  re_author: /\b(?:author|contact|editor|translator|writer)\b|筆者|著者|編(?:者|集[部者])|翻訳者|自己紹介|会社(?:案内|概要)|管理人|メ[ーイ]ル[ ・]?フォーム/i,
+  re_author_2: /メ[ーイ]ル|ﾒｰﾙ|問い?合わ?せ|要望|意見|感想|連絡|に基づく表示/,
+  re_alternate_2: /\b(?:big-?5|chinese|cns|english|french|gb|japanese|korean|flash|pdf|print|frame|no ?frames?)\b|中国語|中文|英[語文]|日本語|日文|韓国語|朝鮮語|ハングル|印刷[版用]|フレーム版|\bi[ -ｰー‐―]?(?:mode|モード)|携帯版/i,
 
   // regular expressions used for identifying links based on the src url of contained images
-  img_re_first: /first/i,
+  img_re_first: /first|homepage/i,
   img_re_prev:  /rev/i, // was /p?rev/
-  img_re_next:  /ne?xt|more|fwd/i,
+  img_re_next:  /ne?xt|more|fwd|enter/i,
   img_re_last:  /last/i,
+  img_re_contents: /contents|to[cp]|menu/i,
+  img_re_index: /in?de?x/i,
+  img_re_author: /mail/i,
+  img_re_alternate: /chin(?:a|ese)|eng(?:lish)?|ja\b|ja?pa?n?(?:ese)?|print(?:er)?|trad(?:itional)/i,
 
   findLinks: function(doc) {
     var i, j, link;
@@ -21,21 +50,24 @@
     var noTop = true, noUp = true, noPrev = true, noNext = true;
     for(i = 0; (noTop || noUp || noPrev || noNext) && i < doc.__lt__links.length; i++) {
       link = doc.__lt__links[i];
-      if("top" in link.relValues) noTop = false;
-      if("up" in link.relValues) noUp = false;
+      //if("top" in link.relValues) noTop = false;
+      //if("up" in link.relValues) noUp = false;
       if("prev" in link.relValues) noPrev = false;
       if("next" in link.relValues) noNext = false;
     }
 
-    if(!noUp || !noTop || !noPrev || !noNext) return;
-
-    var addedLinks = this.scanPageLinks(doc);
-
     // xxx it seems not all documents have this
     var url = doc.location.href;
 
-    noTop = noTop && !("top" in addedLinks);
-    noUp  = noUp  && !("up"  in addedLinks);
+    if(!noUp || !noTop || !noPrev || !noNext) {
+      this.getLinksFromUrl(doc, url, noTop, noUp, noPrev, noNext);
+      return;
+    }
+
+    var addedLinks = this.scanPageLinks(doc);
+
+    //noTop = noTop && !("top" in addedLinks);
+    //noUp  = noUp  && !("up"  in addedLinks);
     noPrev = noPrev && !("prev" in addedLinks);
     noNext = noNext && !("next" in addedLinks);
     this.getLinksFromUrl(doc, url, noTop, noUp, noPrev, noNext);
@@ -111,10 +143,26 @@
         continue; // no point using the regexps
       }
 
-      if(this.re_next.test(title)) rels["next"] = true;
-      else if(this.re_prev.test(title)) rels["prev"] = true;
-      else if(this.re_first.test(title)) rels["first"] = true;
-      else if(this.re_last.test(title)) rels["last"] = true;
+
+      var relFound = false;
+      for (var rel in {top:1, first:1, last:1, next:1, prev:1, contents:1,
+                       part:1, chapter:1, section:1, subsection:1, appendix:1,
+                       index:1, glossary:1, copyright:1, help:1,
+                       search:1, news:1, author:1}) {
+        if (this["re_" + rel].test (title)) {
+          rels[rel] = true;
+          relFound = true;
+          break;
+        }
+      }
+      if (!relFound) {
+        for (var rel in {up:1, first:1, last:1, next:1, prev:1, copyright:1,
+                         help:1, history:1, author:1, alternate:1}) {
+          if (this["re_" + rel + "_2"].test (title)) {
+            rels[rel] = true;
+          }
+        }
+      }
 
       for(var rel in rels) this.addLink(doc, href, rel, title, title, addedLinks);
     }
@@ -180,7 +228,11 @@
       else if(this.img_re_prev.test(src)) rels["prev"] = true;
       else if(this.img_re_first.test(src)) rels["first"] = true;
       else if(this.img_re_last.test(src)) rels["last"] = true;
-      return s;
+      else if(this.img_re_contents.test(src)) rels["contents"] = true;
+      else if(this.img_re_index.test(src)) rels["index"] = true;
+      else if(this.img_re_author.test(src)) rels["author"] = true;
+      else if(this.img_re_alternate.test(src)) rels["alternate"] = true;
+      return src;
     }
     // deal with other elements
     var kids = el.childNodes;
