function detect() {
	// simplify things
	var agent 	= navigator.userAgent.toLowerCase();

	// detect platform
	this.isMac		= (agent.indexOf('mac') != -1);
	this.isWin		= (agent.indexOf('win') != -1);
	this.isWin2k	= (this.isWin && (
			agent.indexOf('nt 5') != -1));
	this.isWinSP2	= (this.isWin && (
			agent.indexOf('xp') != -1 || 
			agent.indexOf('sv1') != -1));
	this.isOther	= (
			agent.indexOf('unix') != -1 || 
			agent.indexOf('sunos') != -1 || 
			agent.indexOf('bsd') != -1 ||
			agent.indexOf('x11') != -1 || 
			agent.indexOf('linux') != -1);
	
	// detect browser
	this.isSafari	= (agent.indexOf('safari') != -1);
	this.isSafari3 = (this.isSafari && agent.search(/like Gecko\) Version\/[\d.]+ Safari/i));
	var webkit = agent.match(/applewebkit\/([\d.]+)/);
	this.isSafari2 = (this.isSafari && !this.isSafari3 && (webkit != null) && (webkit.length >= 2) && (parseFloat(webkit[1]) >=  300));

	this.isOpera	= (agent.indexOf('opera') != -1);
	this.isNN		= (agent.indexOf('netscape') != -1);
	this.isIE		= (agent.indexOf('msie') != -1);
	this.isFF		= (agent.indexOf('firefox') != -1);
	this.isMozOne	= ((agent.indexOf('Mozilla/5.0') != -1) && (agent.indexOf('rv:1.0') != -1));
}
var browser = new detect();


/*
	stack up multiple events on (ususlly window) events such as onload, onunload, onresize
	stack_handler(window,'onload',function(){});
*/
function stack_handler(obj, event, func) {	
	var old_func = obj[event];
	if (typeof old_func != 'function') {
		obj[event] = func;
	} else {
		obj[event] = function() {
			old_func();
			func();
		}
	}
}


var rollover_dont_click = false;	//can be set to true to stop click handling (eg on page editor)

function rollover_event(e) {
	if (rollover_dont_click) return true;	//if true turns off the whole rollover thing

	var elem = Event.element(e);
	var target = elem;
	while (elem && (!elem.className  || !Element.hasClassName(elem, 'rollover'))) elem = elem.parentNode;	//scan up to the hot item (from its children)

	if (e.type == 'click') {
		
		if (target.onclick) return true;	//hot item has an on click so do that rather than anything here.
		
		if (target && target.tagName && (target.tagName.toLowerCase() == 'a')) return true;	//click on an anchor so just let it work as normal
		
		if (target.href) window.top.location.href = target.href;	//hot item has an href property so use it.
			
		var anchors = elem.getElementsByTagName('a');	//if not find first anchor in child nodes
		if (anchors) for(var i=0;i<anchors.length;i++) if (anchors[i].href) {
			window.top.location.href = anchors[i].href;
			break;
		}
		
		return false;
		
	} else {
	
		if (elem) {
			var elemhot = (elem && elem.className && Element.hasClassName(elem, 'rollover'));
		}
		
		if (document.rollover_last && ((document.rollover_last != elem) || !elemhot)) {
			Element.removeClassName(document.rollover_last, 'hover');
			document.rollover_last = false;
		}
		if (elemhot) {
			document.rollover_last = elem;
			Element.addClassName(elem, 'hover');
		}
	}
}	



function rollover_make() {
	var items = document.getElementsByClassName('rollover');

	if (items) {
		for(var i=0;i<items.length;i++) {
			if (items[i]) {
				Event.observe(items[i], "click", rollover_event);
			}
		}
		Event.observe(document, "mouseover", rollover_event);
		Event.observe(document, "mouseout", rollover_event);
	}
}



stack_handler(window,'onload', rollover_make);


// :o)