Object.extend(Event, (function() { var cache = { };  function getEventID(element) { if (element._eventID) return element._eventID; arguments.callee.id = arguments.callee.id || 1; return element._eventID = ++arguments.callee.id; }  function getDOMEventName(eventName) { if (!Event.DOMEvents.include(eventName)) return "dataavailable"; return { keypress: "keydown" }[eventName] || eventName; }  function getCacheForID(id) { return cache[id] = cache[id] || { }; }  function getWrappersForEventName(id, eventName) { var c = getCacheForID(id); return c[eventName] = c[eventName] || []; }  function createWrapper(id, eventName, handler) { var c = getWrappersForEventName(id, eventName); if (c.pluck("handler").include(handler)) return false;  var wrapper = function(event) { if (event.eventName && event.eventName != eventName) return false;  Event.extend(event); handler.call(event.target, event); };  wrapper.handler = handler; c.push(wrapper); return wrapper; }  function findWrapper(id, eventName, handler) { var c = getWrappersForEventName(id, eventName); return c.find(function(wrapper) { return wrapper.handler == handler }); }  function destroyWrapper(id, eventName, handler) { var c = getCacheForID(id), name = getDOMEventName(eventName); if (!c[name]) return false; c[name] = c[name].without(findWrapper(id, eventName, handler)); }  function destroyCache() { for (var id in cache) for (var eventName in cache[id]) cache[id][eventName] = null; }  if (window.attachEvent) { window.attachEvent("onunload", destroyCache); }  return { observe: function(element, eventName, handler) { element = $(element); var id = getEventID(element), name = getDOMEventName(eventName);  var wrapper = createWrapper(id, eventName, handler); if (!wrapper) return false;  if (element.addEventListener) { element.addEventListener(name, wrapper, false); } else { element.attachEvent("on" + name, wrapper); } },  stopObserving: function(element, eventName, handler) { element = $(element); var id = getEventID(element), name = getDOMEventName(eventName);  if (!handler && eventName) { return getWrappersForEventName(id, eventName).each(function(wrapper) { element.stopObserving(eventName, wrapper.handler); }) && false;  } else if (!eventName) { return Object.keys(getCacheForID(id)).each(function(eventName) { element.stopObserving(eventName); }) && false; }  var wrapper = findWrapper(id, eventName, handler); if (!wrapper) return false;  if (element.removeEventListener) { element.removeEventListener(name, wrapper, false); } else { element.detachEvent("on" + name, wrapper); } },  fire: function(element, eventName, memo) { element = $(element); if (element == document && document.createEvent && !element.dispatchEvent) element = document.documentElement;  if (document.createEvent) { var event = document.createEvent("Events"); event.initEvent("dataavailable", true, true); } else { var event = document.createEventObject(); event.eventType = "ondataavailable"; }  event.eventName = eventName; event.memo = memo || {};  if (document.createEvent) { element.dispatchEvent(event); } else { element.fireEvent(event.eventType, event); }  return element; } }; })()); 
return function(event) { if (event._extendedByPrototype) return event; return Object.extend(event, methods); }; 
Object.extend(Event, (function() {  var cache = { };    function getEventID(element) {    if (element._eventID) return element._eventID;    arguments.callee.id = arguments.callee.id || 1;    return element._eventID = ++arguments.callee.id;  }    function getDOMEventName(eventName) {    if (!Event.DOMEvents.include(eventName)) return "dataavailable";    return { keypress: "keydown" }[eventName] || eventName;  }    function getCacheForID(id) {    return cache[id] = cache[id] || { };  }    function getWrappersForEventName(id, eventName) {    var c = getCacheForID(id);    return c[eventName] = c[eventName] || [];  }    function createWrapper(id, eventName, handler) {    var c = getWrappersForEventName(id, eventName);    if (c.pluck("handler").include(handler)) return false;        var wrapper = function(event) {      if (event.eventName && event.eventName != eventName)        return false;            Event.extend(event);      handler.call(event.target, event);    };        wrapper.handler = handler;    c.push(wrapper);    return wrapper;  }    function findWrapper(id, eventName, handler) {    var c = getWrappersForEventName(id, eventName);    return c.find(function(wrapper) { return wrapper.handler == handler });  }    function destroyWrapper(id, eventName, handler) {    var c = getCacheForID(id), name = getDOMEventName(eventName);    if (!c[name]) return false;    c[name] = c[name].without(findWrapper(id, eventName, handler));  }    function destroyCache() {    for (var id in cache)      for (var eventName in cache[id])        cache[id][eventName] = null;  }    if (window.attachEvent) {    window.attachEvent("onunload", destroyCache);  }    return {    observe: function(element, eventName, handler) {      element = $(element);      var id = getEventID(element), name = getDOMEventName(eventName);            var wrapper = createWrapper(id, eventName, handler);      if (!wrapper) return false;            if (element.addEventListener) {        element.addEventListener(name, wrapper, false);      } else {        element.attachEvent("on" + name, wrapper);      }    },      stopObserving: function(element, eventName, handler) {      element = $(element);      var id = getEventID(element), name = getDOMEventName(eventName);            if (!handler && eventName) {        return getWrappersForEventName(id, eventName).each(function(wrapper) {          element.stopObserving(eventName, wrapper.handler);        }) && false;              } else if (!eventName) {        return Object.keys(getCacheForID(id)).each(function(eventName) {          element.stopObserving(eventName);        }) && false;      }            var wrapper = findWrapper(id, eventName, handler);      if (!wrapper) return false;            if (element.removeEventListener) {        element.removeEventListener(name, wrapper, false);      } else {        element.detachEvent("on" + name, wrapper);      }    },      fire: function(element, eventName, memo) {      element = $(element);      if (element == document && document.createEvent && !element.dispatchEvent)        element = document.documentElement;              if (document.createEvent) {        var event = document.createEvent("Events");        event.initEvent("dataavailable", true, true);      } else {        var event = document.createEventObject();        event.eventType = "ondataavailable";      }      event.eventName = eventName;      event.memo = memo || {};      if (document.createEvent) {        element.dispatchEvent(event);      } else {        element.fireEvent(event.eventType, event);      }      return element;    }  };})());
5582	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/5582/cbaec757e2064d53466aea82c2ca25238ce84004/event.js/buggy/src/event.js