// 関連文献リストの非同期更新
document.observe('dom:loaded', function() {
    var body = $(document.body);
    var related_articles = body.down('#result_detail table tr td.related_articles div');
    if (related_articles) {
      // window.location オブジェクトの値の例
      // 
      // href		http://test2011.sciencelinks.jp/j-east/display.php?id=000019990599A0120737
      // pathname	/j-east/display.php
      // search		?id=000019990599A0120737
      // 
      // href		http://test2011.sciencelinks.jp/j-east/display.php?id=000019990599A0120737&profiling=1
      // pathname	/j-east/display.php
      // search		?id=000019990599A0120737&profiling=1
      //
      // href		http://test2011.sciencelinks.jp/j-east/article/199905/000019990599A0120737.php
      // pathname	/j-east/article/199905/000019990599A0120737.php
      // search		(空文字列)
      //
      // href		http://test2011.sciencelinks.jp/j-east/article/199905/000019990599A0120737.php?profiling=1
      // pathname	/j-east/article/199905/000019990599A0120737.php
      // search		?profiling=1
      //

      // window.location.search から GET パラメータを取り出す。
      // window.location.href はパラメータなしの場合に余計な要素が含ま
      // れるので避ける。
      var params = window.location.search.toQueryParams();
      params.task = 'related_articles';

      // 準静的ページの場合は window.location.pathname(「?」以降は含ま
      // れない)から id を取り出す
      if (!params.id && window.location.pathname.match(/(\w{10,}).php$/i)) {
	params.id = RegExp.$1;
      }
	
      if (params.id) {
	new Ajax.Updater(related_articles, '/j-east/display.php', {parameters: params});
      } else {
	related_articles.update('Invalid request');
      }
    }
  });

