// Used to add more than one handler to the load event by Simon Willison
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// Finds element which triggers the event
function find_target(e) {
	/* Begin the DOM events part, which you */
	/* can ignore for now if it's confusing */
	var target; 

	if (window.event && window.event.srcElement) 
		target = window.event.srcElement;
	else if (e && e.target)
		target = e.target;
	if (!target)
		return null;

	return target;
}

// cross-browser event handling for IE5+, NS6+ and Mozilla/Gecko
// By Scott Andrew
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture); 
		return true; 
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn); 
		return r; 
	} else {
		elm['on' + evType] = fn;
	}
}