Behaviour.register({
	'#menu' : function(el){
		// we basically change 'over' to 'active' so javascript can do cool stuff with menu
		// while people without javascript see the activated menu
		// but we only need to run it once otherwise it won't work
		if (!this.hasRan){
			this.hasRan = true;
			var i, nodes = el.getElementsByTagName('LI');
			for (i in nodes){
				if (nodes[i].className == 'over'){
					nodes[i].className = 'active';
				}
			}
		}
	},
	'#menu li' : function(el){
		el.onmouseover = function(){
			$A(this.parentNode.childNodes).each(
				function(n){ if (n.tagName == 'LI') n.className = n.className.replace(/\bover\b/gi,""); }
			);
			this.className = this.className ? this.className+" over" : "over";
		};
		el.onmouseout = function(){
			this.className = this.className.replace(/\bover\b/gi,"");
			Behaviour.apply();
		};
	},
	'#menu li.active' : function(el){
		el.className += " over";
	},
	
	// open external links in a new window
	'A' : function(el){
		if (!el.target && (el.href.indexOf(window.location.hostname) == -1 || el.href.indexOf('.pdf') != -1)){
			el.target = "_blank";
		}
	},
	
	// and do the same with image maps
	'AREA' : function(el){
		if (!el.target && el.href.indexOf(window.location.hostname) == -1 || el.href.indexOf('.pdf') != -1){
			el.target = "_blank";
		}
	}
	
});

/** prevent flicker on menu images **/

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
	
	

/** add in slideshow code **/
var AdzSlideShow = Class.create();
AdzSlideShow.prototype = {
	initialize : function(el){
		this.el = $(el);
		el.cleanWhitespace();
		this.current = $(el.firstChild);
	},
	prev : function(){
		var el = $(this.current.previousSibling);
		if (el){
			this.current.setStyle({zIndex:1});
			el.setStyle({zIndex:2});
			this.current = el;
		}
	},
	next : function(){
		var el = $(this.current.nextSibling);
		if (el){
			if (!el.firstChild) {
				var c = this.current.firstChild.cloneNode(true);
				c.src = el.className;
				el.appendChild(c);
				el.className = '';
			}
			this.current.setStyle({zIndex:1});
			el.setStyle({zIndex:2});
			this.current = el;
		}
	}
};
