If a global variable is 'undefined' when you read it inside a function it is most likely not a global variable in the first place or wrongly declared to begin with.
Seeing some of your code, you indeed have some trouble with that.
Remember that every variable you use must be declared first. If you don't do that JScript will do it for you but this makes bad code and is prone to mistakes and confussion (as shown in your code with the 'Window' variable.)
The first time you use a variable make it a habit to always declare it using the 'var' statement. Depending on where this var statement occurs it is a global variable (when the declaration is done outside a function) or a local variable (when it is done inside the function; and this means the variable will only be valid inside this function).
Also don't confuse parameters of funtions with variables, those are two different things (again refering to the use of the 'Window' variable inside the OnMainEvent_CtrlClicked function which is of no need since 1) it isn't delcared properly and 2) the function already passed the window object as a variable).
------------
Your script has, besides the stuff I already said, other issues as well.
Eg: when contacts are added or removed from the contact list, your script will leave entries for those contacts in the registry or even malfunction.
Eg: In convo's with multiple contacts your script doesn't behave as intended.
------------
PS: also the XML file has same strange things in it, making me believe you copied it from somewhere else maybe (?)...
No need for the global colors definition.
Also the name value of the interfaces tag seems a bit strange...
------------
Attached is the rewritten and optimized script (without the use of timers and registry (and also compatible with Plus!3 format codes)).
If you wish you can take a look at it, and use it. If you don't wish and want to do it all yourself first, ignore it for now
EDIT: updated, editing 1 line to be even more shorter....