function appendMarker(e, marker, place) {
  var img = document.createElement("img");
  img.src    = marker.src;
  img.width  = marker.w;
  img.height = marker.h;
  img.title  = marker.title;
  if (place == "head") {
    e.insertBefore(img, e.firstChild);
  } else {
    e.appendChild(img);
  }
}
(function() {
  var marker = {
  yu:   {src: "img/icon_link_yu3c.gif",    w: 15, h: 9, title: ""},
  secyu:{src: "img/icon_link_secyu1c.gif", w: 15, h:14, title: ""},
//  secyu:{src: "img/icon_link_secyu2c.gif", w: 15, h:15, title: ""},
//  secyu:{src: "img/icon_link_secyu3c.gif", w: 25, h: 9, title: ""},
  ext:  {src: "img/icon_link_ext1c.gif",   w: 16, h:16, title: ""},
  mail: {src: "img/icon_link_mail.gif",    w: 15, h: 9, title: ""},
  pdf:  {src: "img/icon_pdf_16x16.png",    w: 16, h:16, title: ""},
  doc:  {src: "img/icon_doc_16x16.png",    w: 16, h:16, title: ""},
  xls:  {src: "img/icon_xls_16x16.png",    w: 16, h:16, title: ""},
  mp3:  {src: "img/icon_mp3_16x16.png",    w: 16, h:16, title: ""},
  dummy4ie: {}
  };
  var baseurl = "";
  if (document.location.toString().match("^(.*://[^/]*/)")) {
    baseurl = RegExp.$1;
  }
  var ev = "load";
  var attacher = "addEventListener";
  if (window.attachEvent) {
    ev = "onload";
    attacher = "attachEvent";
  }
  window[attacher](ev,function(){
    var a = document.getElementsByTagName("a");
    for(var i = a.length - 1; 0 <= i; i--) {
      var sep = "";
      if (a[i].href.indexOf(baseurl) == 0) {
        //
      } else if (a[i].href.match('^https://[^/]*yamaguchi-u.ac.jp/.*') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.secyu);
      } else if (a[i].href.match('^http://[^/]*yamaguchi-u.ac.jp/.*') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.yu);
      } else if (a[i].href.match('^http://133.62.') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.yu);
      } else if (a[i].href.match('^mms://[^/]*yamaguchi-u.ac.jp/.*') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.yu);
      } else if (a[i].href.match('^https?://') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.ext);
      } else if (a[i].href.match('^mailto:') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.mail);
      }
      if (false) {
      } else if (a[i].href.match('.pdf$') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.pdf);
      } else if (a[i].href.match('.doc$') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.doc);
      } else if (a[i].href.match('.xls$') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.xls);
      } else if (a[i].href.match('.mp3$') && a[i].firstChild && a[i].firstChild.tagName != "IMG") {
        appendMarker(a[i], marker.mp3);
      }
    }
  }, true);
})();

