/********************************************************
 * Copyright (C) 2002-2003, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 *
 * CodeHouse.com JavaScript Library Module: Register Event Class
 *
 * You can obtain this script at http://www.codehouse.com
 *
 * http://www.codehouse.com/javascript/scripts/cjl/register_event/
 *
 ********************************************************/

function CJL_RegisterEvent(elem, type, listener, useCapture, noAutoStart)
{
   var proto = arguments.callee.prototype;
   this.e = elem;
   this.type = type;
   this.cap = useCapture;
   this.l = listener;
   proto.start = function()
   {
      if(this.e.attachEvent)
      {
         this.e.attachEvent("on" + this.type, this.l);
      }
      else if(this.e.addEventListener)
      {
         this.e.addEventListener(this.type, this.l, this.cap);
      }
   }
   if(!noAutoStart)
   {
      this.start(elem, type, listener);
   }
   proto.stop = function()
   {
      if(this.e.detachEvent)
      {
         this.e.detachEvent("on" + this.type, this.l);
      }
      else if(this.e.removeEventListener)
      {
         this.e.removeEventListener(this.type, this.l, this.cap);
      }
   }
}

