The problem is that javascript can not find heartbeat() when it's being run. You should either declare your function out of the plugin (global namespace) or refer to your function with the full path ($.plugin.func()). Of course you'd need to rewrite your code a little...
Code:
function heartbeat() { ... };
$.Plugin = function(obj,opt)
{
init();
function init() { ... };
setTimeout('heartbeat();', 1000);
}