/* smoothscroll */
var ss_INTERVAL;
var ss_STEPS = 25;

function smoothScroll(anchor) {
	var allLinks = document.getElementsByTagName('a');
	var destinationLink = null;
	for (var i=0;i<allLinks.length;i++) {
		var lnk = allLinks[i];
		if (lnk.name && (lnk.name == anchor)) {
			destinationLink = lnk;
			break;
		}
	}
	
	if (!destinationLink) return true;
	
	var destx = destinationLink.offsetLeft;  
	var desty = destinationLink.offsetTop;
	var thisNode = destinationLink;
	while (thisNode.offsetParent &&  
		(thisNode.offsetParent != document.body)) {
	thisNode = thisNode.offsetParent;
	destx += thisNode.offsetLeft;
	desty += thisNode.offsetTop;
		}
		
		clearInterval(ss_INTERVAL);
		
		cypos = ss_getCurrentYPos();
		
		ss_stepsize = parseInt((desty-cypos)/ss_STEPS);
		ss_INTERVAL = setInterval('ss_scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
		
}

function ss_scrollWindow(scramount,dest,anchor) {
	wascypos = ss_getCurrentYPos();
	isAbove = (wascypos < dest);
	window.scrollTo(0,wascypos + scramount);
	iscypos = ss_getCurrentYPos();
	isAboveNow = (iscypos < dest);
	if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
		window.scrollTo(0,dest);
		clearInterval(ss_INTERVAL);
		location.hash = anchor;
	}
}

function ss_getCurrentYPos() {
	if (document.body && document.body.scrollTop)
		return document.body.scrollTop;
	if (document.documentElement && document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
	if (window.pageYOffset)
		return window.pageYOffset;
	return 0;
}