auto discover document links and apply class

This will look through every a element on the page. If the href attribute of it has a .doc, .xls, or .pdf in it, it will apply the appropriate class name to it (e.g. class="doc")

$('a[href]').each(function() {
   if((C = $(this).attr('href').match([.](doc|xls|pdf)$))) {
       $(this).addClass(C[1]);
   }
});