(function() {

//	select all anchors with a # at the start of the href attribute
function init() {
	var scrollFx = new Fx.Scroll(window,
								 {
									 'transition' : Fx.Transitions.Cubic.easeInOut,
									 'duration' : '2000'
								 }); 
	
	function clickHandler(event,target)
	{
		event = new Event(event);
		event.stop();
		
		scrollFx.toElement(target);
	}
	
	
	function handleAnchors(item,index)
	{
		target = item.href.split('#')[1];
		
		item.addEvent('click',clickHandler.bindWithEvent(this,[target]));
	}
	
	$$('a[href^=#]').forEach(handleAnchors);
}

window.addEvent('load',init);
})();
