/**
 * Title: Events Object
 * Date Created: 2005/12/27
 * Description: Cross-browser event attachment/detachment
 *              methods and event types.
 * Amendment History:
 * Copyright (c) 2004
 * Company: Azeus Systems Philippines Inc.
 * @author Daniw
 */

var events = {
  CLICK: "click",
  MOUSE_OVER: "mouseover",
  CHANGE: "change",
  BLUR: "blur",
  SELECT: "select",
    
  /**
   * Cross-browser way of attaching an event to an element.
   * Example usage: document.addEvent("PERSON_NAME", "blur", trim);
   *
   * @param anElement - a reference to the element
   * @param anEventType - the event type to be used, excluding the "on"; for example, "click", or "mouseover"
   * @param aFunctionReference - the reference to the function, not the function's result
   */
  addEvent: function(anElement, anEventType, aFunctionReference) {
	  if (anElement && anEventType && aFunctionReference) {
	    if (anElement.addEventListener) {
			  anElement.addEventListener(anEventType, aFunctionReference, false); 
			} else if (anElement.attachEvent) {
			  anElement.attachEvent("on" + anEventType, aFunctionReference);
			}
	  }
  },

	/**
	 * Cross-browser way of removing an event from an element.
	 * Example usage: document.removeEvent("PERSON_NAME", "change", trim);
	 *
	 * @param anElement - a reference to the element
	 * @param anEventType - the event type to be used, excluding the "on"; for example, "click", or "mouseover"
	 * @param aFunctionReference - the reference to the function, not the function's result
	 */
  removeEvent: function(anElement, anEventType, aFunctionReference) {  
    if (anElement && anEventType && aFunctionReference) {
      if (anElement.removeEventListener) {
        anElement.removeEventListener(anEventType, aFunctionReference, false);
      } else if (anElement.detachEvent) {
        anElement.detachEvent("on" + anEventType, aFunctionReference);
      }
    }
  }
}
