/* when the dom is ready */
window.addEvent('domready',function() {
	/* get the links */
	var links = $$('#print-content-area a');
	
	/* remove from the array named anchors lacking an "href" property */
	function notNull(a) {
		return(a.get('href') != undefined);
	}
	var filteredLinks = links.filter(notNull);

	/* if there are any */
	if(filteredLinks.length) {
		/* create toc list */
		var container = new Element('ol',{
			'class': 'print-only toc-list'
		}).inject(document.body,'bottom');
		/* add a heading for the TOC */
		var explanation = new Element('p',{
				text: 'Note: Links in this list that start with "/" or ".." should be preceded by "http://www.ll.georgetown.edu" when you type them into your browser. For example, if the link shown is "../connect/academic.cfm", type "http://www.ll.georgetown.edu/connect/academic.cfm" into your browser.'
		}).inject(container, 'top');
		var header = new Element('h3',{
				text: 'Links In This Document'
		}).inject(container,'top');
		/* get links inside the content area */
		filteredLinks.each(function(a,i) {
			/* insert the span reference right after the link */
			/*if(a.get('href') != undefined){*/
				new Element('span',{
					text: '[' + (i + 1) + ']',
					'class': 'print-only'
				}).inject(a,'after');
				/* record anchor, put in list */
				new Element('li',{
					text: a.get('href')
				}).inject(container,'bottom');
			/*}*/
		});
	}
});
