$(document).ready(function(){
	//get the container and target
	var links = $('#middle_col a[href]:not([href^=#],[href^=mailto],[rel=nofollow],[href^=javascript])');

	if($(links).length){
		//create a container and heading for the footnotes
		var footnotesWrapper = $('<fieldset>', {}).addClass('print_only').css({clear:'both'});
		var footnotesLabel = $('<legend>', {}).appendTo(footnotesWrapper).text('Website Addresses Used in the Document');
	
		//create an OL to hold the footnotes
		var footnoteList = $('<ol>').appendTo(footnotesWrapper);

		$.each(links, function(i){
			var linkURL = $(this).attr('href');
			if(linkURL.substring(0,1) === '/'){
				linkURL = 'http://'+document.location.host + linkURL;
			}
			//create element to hold span with class to hide except on print
			var newElement = $('<span>', {}).addClass('print_only').appendTo($(this)).text(' ['+ ++i +']');
			var listEntry = $('<li>', {}).appendTo(footnoteList).text(linkURL);
		});

		// append the heading and <ol> to the target
		$('#middle_col').append(footnotesWrapper);
	}
});

