(function($)
{
    $.fn.myPlugin = function(options)
    {
        var _this;
        var timer1;
        var foo = function(n)
        {
            if (timer1 != null) return; // in action
            timer1 = setInterval("bar("+n+")", 500);
        };
        var bar = function(n)
        {
            ...
            if ( ... ) clearInterval(timer1);
        };                      
        return this.each(function()
        {
            _this = $(this);
            _this.bind("click", function(){ foo(10); });            
        });
    }
})(jQuery);
This doesn't work because "bar is not defined."