// http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
// http://ejohn.org/projects/flexible-javascript-events/
// enhanced according to http://dean.edwards.name/weblog/2005/12/js-tip1 (Dean Edwards)
// -> the if() now only runs once.
// by Anders Nawroth
// also changed varName = null; to delete varName;

var addEvent;
var removeEvent;

if (document.addEventListener)
{
	addEvent = function ( obj, type, fn, capture )
	{
		obj.addEventListener( type, fn, capture );
	};
	removeEvent = function ( obj, type, fn, capture )
	{
		obj.removeEventListener( type, fn, capture );
	};
}
else if (document.attachEvent)
{
	addEvent = function( obj, type, fn )
	{
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	};
	removeEvent = function( obj, type, fn )
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		delete obj[type+fn];
		delete obj["e"+type+fn];
	}
}
else
{
	// sorry, no support!
	addEvent = Function;
	removeEvent = Function;
}


/*
AddEvent Manager (c) 2005 Angus Turnbull http://www.twinhelix.com
Free usage permitted as long as this credit notice remains intact.
*/
// ** REST OF SCRIPT NOT USED HERE **
// Optional cancelEvent() function you can call within your event handlers to
// stop them performing the normal browser action or kill the event entirely.
// Pass an event object, and the second "c" parameter cancels event bubbling.
function cancelEvent(e, c)
{
 e.returnValue = false;
 if (e.preventDefault) e.preventDefault();
 if (c)
 {
  e.cancelBubble = true;
  if (e.stopPropagation) e.stopPropagation();
 }
};

