
// Hover Behaviour for Nav etc.
var HoverBehavior = Class.create();
HoverBehavior.prototype = {
	initialize: function() {
		// Check for base.href because IE doesn't let us scan CSS remotely
		var local = document.getElementsByTagName('base').length == 0;
		if(local){
			$A(document.styleSheets).each( function(stylesheet) {
				$A(stylesheet.rules).each( function(rule) {
					if( rule.selectorText.match(/:hover/i) ) {
						stylesheet.addRule( rule.selectorText.replace(/:hover/ig, '.hover'), rule.style.cssText );
					}
				});
		
			});
		}

		$A(arguments).each( function(arg) {
			$$(arg).each( function(tag) {
				Event.observe(tag, 'mouseover', function() { Element.addClassName(tag, 'hover'); });
				Event.observe(tag, 'mouseout', function() { Element.removeClassName(tag, 'hover'); });
			});
		});
	}
};

// Global Window Onload
Event.observe(window, 'load',
	function() {
		new HoverBehavior('#nav li');
	}
);