I had to do this awhile back and Hikaru helped me with it
I'd Put this in a class and made the other class trigger each other.
PHP Code:
this.join("class");
class::FunctionInClass();
I did the above on serverside so I'm not sure if it would work on the clientside part of the class.
Then whenever I need the function I can simply use the function
PHP Code:
FunctionInClass( var1, var2);