Changing ichat status

This is part of a script that is run whenever an event goes off in iCal: the other part of the script collect the new status message from the iCal event and the time it will finish and then call this portion, passing the values over.

The purpose of this portion is to collect the current status and statusmessage from iChat, change it accordingly to the info passed by the previous portion and then when the event is over, restore the original status and message.

The problem with this script, that I cannot seem to resolve, is this: when ever the event happens, in addition to this script being launched, iChat also display a message (2 alarms are present on this specific events), however while this script is running the panel showing the message from within ical is frozen (if you click on the close button, it does not highlight and even clicking on the X next to the event do not make it disappear), that is, until the event concludes and at that point (if you clicked on it to make it disappear earlier) it closes.

Any suggestion on making the message panel behaving as it should?

on setiChatStatus(statusMessage, enddate)
	tell application "System Events"
		if exists process "iChat" then
			tell application "iChat"
				set oldstatus to status
				set oldstatusmsg to status message
				set the status to away
				set status message to statusMessage
				set WaitTime to enddate - (current date)
			end tell
		end if
	end tell
	delay (WaitTime - 5)
	tell application "iChat"
		set the status to oldstatus
		set status message to oldstatusmsg
	end tell
end setiChatStatus

AppleScript: 2.0.1
Browser: Safari 528.16
Operating System: Mac OS X (10.5)