I have a problem. I have two javascript-based "controls" - miniprograms in one WWW page. I load two different scripts. I want to integrate them

You can think about "the control" as about javascript script file with functions.

All "controls" have own functions. I want to catch function calling from each control, and then process functions from another control (another script).

I can change this scripts, so I can integrate in source code. Meaby the sollution is to change thoose functions into events, and then match functions from two different scripts (similar to delegates from C#)? If I only could create my own events - not only based on mouse, and keyboard, but fired while function calling...