//<![CDATA[
/*******************
file: icons.js
purpose: add icons and links to files with cics's site
author: 
*******************/
$(document).ready(function() {

  $('a').filter(function() {
 return this.hostname && this.hostname !== location.hostname;
  }).after(' <img src="/assets/css/images/external.png" alt="external link"/>').attr("target", "_blank");


var fileTypes = {
  doc: 'word.png',
  xls: 'xls.png',
  ppt: 'powerpoint.png',
  pdf: 'acrobat.png'
};
 
// this is like $.each() above, except
// it iterates over the matched elements
$('a').each(function() {
 
  // get a jQuery object for each anchor found
  var $a = $(this);
 
  // get the href attribute
  var href = $a.attr('href');
 
  // get the extension from the href
  var hrefArray = href.split('.');
  var extension = hrefArray[hrefArray.length - 1];
 
  var image = fileTypes[extension];
 
  if (image) {
    $a.css({
      paddingLeft: '15px',
      background: 'transparent url("/assets/css/images/' + image + '") no-repeat center left'
    });
  }
 
});
});
//]]>