document.observe('dom:loaded', function(e)
{
	if ($('anchorlinks')) {

		if (Object.isUndefined(window.anchorElements)) {
			elements = ['h2', 'h3'];
		} else {
			elements = window.anchorElements;
		}

		var ul = $('anchorlinks').appendChild( new Element('ul') );

		elements.each(function(e)
		{
			$$('#content ' + e).each( function (e)
			{
				var id = e.identify();
				ul.appendChild(new Element('li')).appendChild(new Element('a', {'href': '#' + id})).update(e.innerHTML);
			});
		});
	}
});
