function standardizeEvent(arg){
    var e;
    if (!arg) {
        e = window.event;
    } else {
        e = arg;
    }
    if (!e.target) e.target = e.srcElement;
    return e
}

//This is the guts of the changes.  We create an simple handler function
// which will standardize the value of "this" and "e" on the actual worker
// function
function createHandlerFunction(obj, fn){
    var o = new Object;
    o.myObj = obj;
    o.calledFunc = fn;
    o.myFunc = function(ev){
      var e = standardizeEvent(ev);
      e.cancelBubble = true;
      if (e.stopPropagation) e.stopPropagation();
      return o.calledFunc.call(o.myObj, e);
    }
    return o.myFunc;
}

//Only change here is to use the createHandlerFunction
function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, createHandlerFunction(obj, fn), useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, createHandlerFunction(obj, fn));
    return r;
  } else {
    alert("Handler could not be attached");
    return 0;
  }
}

