got the sending of messages to function

needed to use postmessage rather then sendmessage.................