/* Add links to navigation items. Complete navigation item (html element li)
   can be clicked to activate the link. The url from the link with class
   <navigation-link> will be used as a target.

   When links with a class <ext> are clicked the script will ignore the click
   and the original url form the target link will be used.
*/

Event.observe(window, "load", function() {
	var navigation = $("navigation").getElementsByTagName("li");
	for (i=0; i<navigation.length; i++) {
		navigation[i].onmouseover = function() {
			Element.addClassName(this, "over");
		}
		navigation[i].onmouseout = function() {
			Element.removeClassName(this, "over");
		}
		navigation[i].onclick = function(e) {
			if (!e) var e = window.event;
			
			var target = e.target || e.srcElement;
			if (Element.hasClassName(target, "ext")) {
				return true;
			}
			
			var link = document.getElementsByClassName("navigation-link", this)[0].href;
			if (link) {
				window.location = link;
			}
			return true;
		}
	}
});