﻿/*

This JS function requires the jQuery JS library (www.jquery.com)
@author     Glen Swinfield
@version    1.0.0
URL:    http://www.glenswinfield.co.uk/activity/comment/file_extension_classes

*/

 $(document).ready(function(){	
	/* 
	   Apply a class to a link depending on filetype.   
	   Give links that link to downloadable files a class of your choosing and call this function
	   passing that class in the parameters. The example below uses the class 'file'	   
	   The rest is done for you.
    */
	function add_file_class(got_class) {
		$('a.'+got_class).each(function (i) {
			var href = $(this).attr('href').split('.');			
			$(this).addClass(href[href.length - 1]);
		});
	
	}
	// run function
	add_file_class('file');
	
	
});