window.event is null at times. pass the event into the function and access it's target from there.