I think you're looking for the open and close events.
$("#my-table tbody td.foo").tooltip({
content: function () {
// figure out the custom message to be displayed
},
items: "td.foo",
position: {
my: "left+15 center",
at: "left top"
},
show: {
delay: 666
},
open: function (event, ui) {// do stuff when tooltip opens...
},
close: function (event, ui) {// do other stuff when tooltip closes...
}
});