;(function($) {

	$.fn.extend({

		footnotelinks: function() {
			
				return this.each(function() {
				
					var ol = $(document.createElement("ol")).addClass("printOnly");
					
					var myArr = [];
					var thisLink;
					
					var num = 1;
					
					$(this).contents().each(function(i) {
					
						if ($(this).attr("href") || $(this).attr("cite")) {
						
							thisLink = $(this).attr("href") ? $(this).attr("href") : $(this).attr("cite");
							
							var note = $(document.createElement("sup")).addClass("printOnly");
							
							var j = $.inArray(thisLink,myArr);
							
							if (j >= 0) {
							
								note.text(j+1);
							
							} else {
							
								note.text(num);
							
								$(document.createElement("li")).text(thisLink).appendTo(ol);
							
								myArr.push(thisLink);
							
								num++;
							
							}
							
							if (this.tagName.toLowerCase() == "blockquote") {
							
								note.appendTo($(this).children(":last"));
								
							} else {
							
								note.insertAfter($(this));
								
							}
							
						}
					
					});
					
					$(document.createElement("h2")).addClass("printOnly").text("Links").appendTo(this);
					
					ol.appendTo(this);
					
				});
				
			}
			
		});
			
			
})(jQuery);