// © Copyright Kenny Grant 2007 
// Released under the BSD licence

// <a href="#fn1" rel="footnote"></a>
// ...
// <a name="fn1" class="footnote"></a>

var Footnotes = {
	
	// Attach effect to highlight footnotes when footnote links clicked
	// 
	// 
	init : function () {
		
			var anchor_list = $A(document.getElementsByTagName('a'));

			anchor_list.each(function (link) {

				 var rel = String(link.getAttribute('rel'));

				 if (rel == "footnote")
					{
					Event.observe(link,'click',Footnotes.respond_click.bindAsEventListener(Footnotes));
					}

			});
			
	},

	// Respond to click on footnote link
	//
	//
	respond_click: function(event){
		link = 	Event.element(event);
		
		target = link.href.gsub(/.*#/,"");
		
		if ($(target))
			{
			new Effect.ScrollTo(target, {offset: -300, duration:1.0});	
			new Effect.Highlight(target,{ startcolor: '#dddddd', restorecolor: false, duration:2.5});
			
			// would be nice if the element popped out slightly - grow a little then go back to normal size
			
			}

		
		Event.stop(event);
		return false;
	}


};


Event.observe(window,'load',Footnotes.init,false);

