var Event = function()
{
	var EventColl = [];
	var counter = 0;
	
	function Event()
	{
		var self = this;
		
		this.addEvent = function(oElement, handler, callback, capture)
		{
			if (oElement.addEventListener)
			{
				oElement.addEventListener(handler, callback, capture);
			}
			else if(oElement.attachEvent)
			{
				var prop = [handler, callback].join("");
				if (oElement[prop]) return;
				
				if (!EventColl[oElement._eventid])
				{
					oElement._eventid = counter++;
					EventColl[oElement._eventid] = {'oElement' : oElement};
				}
				EventColl[oElement._eventid][prop] = [handler, callback];
				
				oElement[prop] = function()
				{
					callback.call(oElement, event);
				}
				oElement.attachEvent('on' + handler, oElement[prop]);
			}
		}
		
		this.removeEvent = function(oElement, handler, callback, capture)
		{
			if (oElement.removeEventListener)
			{
				oElement.removeEventListener(handler, callback, capture);
			}
			else if (oElement.detachEvent)
			{
				var prop = [handler, callback].join("");
				if (oElement[prop])
				{
					oElement.detachEvent('on' + handler, oElement[prop]);
					oElement[prop] = null;
					EventColl[oElement._eventid][prop] = null;
				}
			}
		}
		
		function breakEventLeak()
		{
			var curr = null;
			var j = null;
			for (var i = 0, len = EventColl.length; i < len; i++)
			{
				curr = EventColl[i];
				for (j in curr)
				{
					if (j != 'oElement')
					{
						self.removeEvent(curr.oElement, curr[j][0], curr[j][1]);
					}
				}
				curr.oElement._eventid = null;
			}
			EventColl = null;
			counter = null;
		}
		if (window.attachEvent) window.attachEvent('onunload', breakEventLeak);
	}
	return new Event();
}();

Event.preventDefault = function(event)
{
	event.returnValue = false;
	if (event.preventDefault)
	{
		event.preventDefault();
	}
}

Event.stopPropagation = function(event)
{
	if (event.stopPropagation)
	{
		event.stopPropagation();
		return;
	}
	event.cancelBubble = true;
}