Ummm. $active can refer to status window so you need to make sure: if $active ischan
EDIT - Never mind. I missed seeing the ison operator is used. :(