// Back to Top smooth scroll functionality
var ScrollLinks = {
	currentHash: false,
	start: function(){
		this.scroll = new fx.Scroll({duration: 1500, transition: fx.sineOut, onComplete: function(){this.end();}.bind(this)});
		this.allinks = $c(document.getElementsByTagName('a'));
		this.allinks.each(function(lnk){
			if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname) 
				|| ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) {
				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);
		if (this.currentHash) {
			this.allinks.each(function(lnk){
				if (lnk.id == ScrollLinks.currentHash){
					if (window.opera) lnk =  [lnk].find('parentNode');
					ScrollLinks.scroll.scrollTo(lnk);
					return;
				}
			});
		}
	},

	end: function(){
		if (!/Konqueror|Safari|KHTML/.test(navigator.userAgent)) window.location.hash = "#"+this.currentHash;
		this.currentHash = false;
	}
}

// onload functions to call
window.onload = function(){
    ScrollLinks.start();
}

// rollover functionality function
function activateRolloverNav() {
	var navcollection = new Array();
	var inc = 0; 
	var alltags = document.getElementById("navigation").childNodes;
	for (i = 0; i < alltags.length; i++){ 
  	if (alltags[i].className == "linkwrap") 
    navcollection[inc++] = alltags[i]; 
	}
	for (var i=0;i<navcollection.length;i++) {
		// add rollover/rollout functions
		navcollection[i].onmouseover = function() {
			this.className = this.className + " hovered";
		}
		navcollection[i].onmouseout = function() {
			this.className = this.className.replace(" hovered", "");
		}
	}
}

// Shows confirmation box before following url
function confirm_action(url, message)
{
	var response = confirm(message);
	if (response == true)
		window.location.href = url;
	else
		return false;
}




