
<!-- As far as I know, this Javascript was written by Tony Yoo: www.tonyyoo.com-->

var ScrollLinks = {
	
	currentHash: false,
	start: function(){
		this.scroll = new fx.Scroll({duration: 800, transition: fx.sineOut, onComplete: function(){this.end();}.bind(this)});
		this.allinks = $c(document.getElementsByTagName('a'));
		
		for(var i=0; i<this.allinks.length; i++) {
			
			var lnk = this.allinks[i]; //changed it from using "each"
			
			if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname)
			|| ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) {
				lnk.num = i;
				lnk.onclick = function(){
					
					ScrollLinks.scroll.clearTimer();
					this.initialHref = this.href;
					this.initialHash = this.hash;
					this.href = "javascript:void(0)";
					setTimeout(function(){this.href = this.initialHref;}.bind(this), 200);
					ScrollLinks.go(this);
				}
			}
		};
	},
	
	go: function(link){
		this.currentHash = link.initialHash.slice(1); // Get the link target
		this.currentBlock = $(this.currentHash);
		if (this.currentBlock) { // Only continue if the target exists
			ScrollLinks.scroll.scrollTo(this.currentBlock);
		}
	},
	
	end: function(){
		if (!/Konqueror|Safari|KHTML/.test(navigator.userAgent)) window.location.hash = "#"+this.currentHash;
		this.currentHash = false;
	}
}

