jQuery plugin gives error "Exception thrown and not caught"

jQuery plugin gives error "Exception thrown and not caught"

I'm a little new at working with jQuery, and especially jQuery plugins. I've written the following script (just a basic tab selector) that I'm trying to convert to a plugin:

      $('#nav li a').bind
      (
         'click',
         
         function(e)
         {
            e.preventDefault();
            
            $(this).parent().parent().children().filter('li').each
            (
               function()
               {
                  $(this).removeClass().addClass('normallink');
                  $($(this).children().filter('a').attr('href')).css('display', 'none');
               }
            );
            
            $(this).parent().removeClass().addClass('activelink');
            $($(this).attr('href')).css('display', '');
         }
      );
      
      $("#nav li a:not(':first')").each
      (
         function()
         {
            $($(this).attr('href')).css('display', 'none');
         }
      );


Works great, so far, but I would like to make it a plugin so all I have to call is $('#nav').tabs();

This is what I have for the plugin, so far:

(function($)
{
   $.fn.tabs = function(e)
   {
      return this.each
      (
         function(e)
         {
            $('li a').bind
            (
               'click',
               
               function(e)
               {
                  e.preventDefault();

                  $(this).parent().parent().children().filter('li').each
                  (
                     function()
                     {
                        $(this).removeClass().addClass('normallink');
                        $($(this).children().filter('a').attr('href')).css('display', 'none');
                     }
                  );

                  $(this).parent().removeClass().addClass('activelink');
                  $($(this).attr('href')).css('display', '');
               }
            );

            $("li a:not(':first')").each
            (
               function()
               {
                  $($(this).attr('href')).css('display', 'none');
               }
            );
         }
      );
   }

})(jQuery);



It does work, but as mentioned in the title, it has an error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Timestamp: Wed, 9 Dec 2009 18:43:16 UTC


Message: Exception thrown and not caught
Line: 19
Char: 2424
Code: 0
URI: http://wwi.chcs-ut.com/members/js/jquery-1.3.2.min.js


I'm sure it's something to do with my selector in the plugin, but I'm not sure what I need to do differently. I know there are existing jquery tab scripts, but this is a good learning experience for me. Any input would be helpful. Thanks!