Ok the problem that your having is that ChatWnd isn't defined as anything. If you look at other examples or even a function (example : )
code:
OnEvent_ChatWndCreated(
[object] ChatWnd
);
You see how ChatWnd is defined as an object. This is there because Plus! passes the chat window object to the function. This cannot be used the way you are doing it. If you make a global variable
code:
var ChatWnd;
And pass the ChatWnd from the OnEvent_ChatWndCreated to our global ChatWnd then you can use it. However this will overwrite the previous windows.
So if you were sending these messages to Person X and you open a conversation with Persion Y you will be sending them to Person Y and not Person X.
Hope that explains why your getting the error and how you can possibly fix it.