﻿
/* Adds file icons to page */
function AddIcons()
{
	var fileTypes = {
		pdf: 'pdf.gif',
		doc: 'doc.gif',
		docx: 'doc.gif',
		xls: 'xls.gif',
		ppt: 'ppt.gif'
	};

	$('a').each(function()
	{
	    var $a = $(this);
	    var href = $a.attr('href');

	    if (href)
	    {
	        var hrefArray = href.split('.');
	        var extension = hrefArray[hrefArray.length - 1];
	        var image = fileTypes[extension];

	        if (image)
	        {
	            $a.css({
	                paddingRight: '18px', paddingBottom: "1px", display: "inline-block",
	                background: 'transparent url("/images/FileIcons/' + image + '") no-repeat center right'
	            });
	        }

            // Adds open in new window to external links
	        if ($a.attr('target') == "_blank")
	        {
	            if (!$a.attr('title'))
	            {
	                $a.attr('title', '[Link opens in new window]');
	            }
	            else
	            {
	                $a.attr('title', $a.attr('title') + ' [opens in new window]');
	            }
	        }

	    }
	});
}

