function applyIcons() {
  links = document.getElementsByTagName("a");
  for (i = 0; i < links.length; i++) {
    ["rtf", "doc", "xls", "pdf", "ppt"].each(function(it){
      if (links[i].href.match("\."+it+"$")) {
        Element.addClassName(links[i], it);
        links[i].setAttribute("title", "Скачать "+links[i].href.split('/').pop());
      }
    });
    if (links[i].href.match('/([^.]+)$') && Element.hasClassName(links[i], "document")) {
      links[i].addClassName("arrow");
    }
  }
}

Event.observe(window, "load", applyIcons, false);