  jQuery(document).ready(function() 
    { 
      var fileTypes = {
        doc:  '/images/icon_word.gif',
        docx: '/images/icon_word.gif',
        pdf:  '/images/icon_pdf.gif',
        ppt:  '/images/icon_powerpoint.gif',
        pptx: '/images/icon_powerpoint.gif',
        xls:  '/images/icon_excel.gif',
        xlsx: '/images/icon_excel.gif',
        zip:  '/images/icon_zip.gif'
    };
      var altText = {
        doc:  'Microsoft Word',
        docx: 'Microsoft Word',
				pdf:  'PDF',
        ppt:  'Microsoft PowerPoint',
        pptx: 'Microsoft PowerPoint',
				xls:  'Microsoft Excel',
				xlsx: 'Microsoft Excel',
		zip: 'Compressed File'
      };
             
			// iterate over the matched elements
			jQuery('a').each(function() {
			 
				// get a jQuery object for each anchor found
				var $a = jQuery(this);
				
				// don't add icons to images that are hyperlinked (eg, lightboxes, PDF thumbnails, etc)
			  if ($a.has('img').length == 0) { 
				
				
					// get the whole href attribute value
					var href = $a.attr('href');
	
					// get the extension from the href
					if(typeof(href) !== 'undefined') {
						var hrefArray = href.split('.');
						var extension = hrefArray[hrefArray.length - 1].toLowerCase();
					 
						var image = fileTypes[extension];
						
						// add the icon!
						if (image) {
							//console.log('image:'+image);	
							jQuery('<img />', {'src': image,
													'alt':  altText[extension],
													'style': 'margin-left:4px; vertical-align:text-top; '}).appendTo($a);
								
						}
				}
			}
			 
			});
		} 
	);
