/**
 * Icons component
 */
var Icons = {
	EXTENSIONS: ["pdf", "xls", "doc", "docx", "xlsx", "png", "gif", "jpg", "xml", "zip", "txt"],

	init: function() {
		$('.downloads a').each(function() {
			try {
				var href = this.href;
				if (href && href.indexOf(".") != -1) {
					var pos = href.lastIndexOf(".");
					var extension = href.substr(pos + 1).toLowerCase();
					if (Icons.EXTENSIONS.indexOf(extension) == -1) {
						extension = "file";
					}
					$(this).addClass('icon ' + extension);
				}
			}
			catch(err) {
				// ignore
			}
		});
	}
};

$(document).ready(function() {
	Icons.init();
});

