/* 
 Modified version of SmoothScroll from http://docs.mootools.net/Plugins/SmoothScroll.js
 
 Note:
	SmoothScroll requires an XHTML doctype.
*/
var SmoothScroll = Fx.Scroll.extend({

	initialize: function(options){
		this.parent(window, options);
		this.links = (this.options.links) ? $$(this.options.links) : $$(document.links);
		var location = window.location.href.match(/^[^#]*/)[0] + '#';
		this.links.each(function(link){
			if (link.href.indexOf(location) != 0) return;
			var anchor = link.href.substr(location.length);
			if (anchor && $(anchor)) this.useLink(link, anchor);
		}, this);
		this.addEvent('onComplete', function(){
			if((this.options.className && !$(this.anchor).hasClass(this.options.className)) && !(this.options.exclude && this.options.exclude.toString().contains(this.anchor))) $(this.anchor).addClass(this.options.className);
			if(!window.webkit419) window.location.hash = this.anchor;
		});
	},

	useLink: function(link, anchor){
		link.addEvent('click', function(event){
			if(this.anchor && $(this.anchor).hasClass(this.options.className)) $(this.anchor).removeClass(this.options.className);
			this.anchor = anchor;
			this.toElement(anchor);
			event.stop();
		}.bindWithEvent(this));
	}
});