// example: modifyEventListener("remove","onmouseup",document,returnTrue);
function modifyEventListener(psAction, psEventName, poElement, poFunction){
	var isAdd = ((psAction == "add")||(psAction == "attach"))?true:false;

	psEventName = psEventName.toLowerCase(); // just in case
	if (psEventName.substring(0,2) != "on") {
		psEventName = "on"+psEventName; // in case they gave click instead of onclick
	}

	if ( poElement.addEventListener ) { // W3C DOM2
		if (isAdd) {
			// strip the 'on' off the front of the event name
			poElement.addEventListener(psEventName.substr(2),poFunction,false);
		} else {
			poElement.removeEventListener(psEventName.substr(2),poFunction,false);
		}
		return true;
	} else if ( poElement.attachEvent ) { // IE5+
		if (isAdd) {
			poElement.attachEvent(psEventName,poFunction);
		} else {
			poElement.detachEvent(psEventName,poFunction);
		}
		return true;
	} else if ( document.getElementById ) { // crappola pre-IE5 or NS6 browsers
		if ( poElement.captureEvents ) { // if NS4 must reg then bind
			var sFunc = (isAdd)?"captureEvents":"releaseEvents";
			// event should strip off 'on' and then uppercase
			eval("poElement."+sFunc+"(Event."+psEventName.substr(2).toUpperCase()+");");
		}
		//if add need the name of the function to use in the eval
		var sFunc = (isAdd)?(poFunction.toString().split(' ')[1].split('(')[0]):"null";
		eval("poElement."+psEventName+" = "+sFunc+";");
		return true;
	}

	return false; // none of the above so no event attached, return false
}

function getEventObject(evt) {
	return (evt) ? evt : ((window.event) ? event : null);
}

function getEventObjectsElement (evt) {
	evt = (evt) ? evt : ((window.event) ? event : null);
	if ( evt ) {
		var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
		// if element contains a text node then need to pop up one
		while ( elem.nodeType == 3 ) {
			elem = elem.parentNode;
		}
		return elem;
	}
	return null;
}