EventHandler = {};

EventHandler.AddEvent = function(AControlId,AEvent,ACallbackFunction) {
	
//get the object
	var Control;
	if (typeof AControlId == 'string') {
		Control = document.getElementById(AControlId); 
	} else {
		Control = AControlId;
	}
//if such an object exists
  if (Control) {
	//if this is DOM-compliant browser 
		if (typeof Control.addEventListener != 'undefined') {
			Control.addEventListener(AEvent,ACallbackFunction,false);
	//otherwise
		} else {
			Control.attachEvent('on' + AEvent,ACallbackFunction);
		}
	}
	
}

EventHandler.GetTarget = function(AEvent) {
	
//if this is DOM-compliant browser 
	if (typeof AEvent.target != 'undefined') {
		return AEvent.target;
//otherwise
	} else {
		return AEvent.srcElement;
	}
	
}

EventHandler.GetKeyPressed = function(AEvent) {
	
//if this is DOM-compliant browser 
  if (typeof AEvent.charCode != 'undefined') {
    return AEvent.charCode;
//otherwise
  } else {
    return AEvent.keyCode;
  }
  
}

EventHandler.CancelBubble = function(AEvent) {
	
	if (typeof AEvent.stopPropagation != 'undefined') {
		AEvent.stopPropagation();
	} else {
		AEvent.cancelBubble = true;
	}

}
