        $.fn.tabs = function () {
            return this.each(function () {
               var $tabwrapper = $(this); 
               
               var $panels = $tabwrapper.find('> div');
               var $tabs = $tabwrapper.find('> ul a');
               
               $tabs.click(function () {  
                   $tabs.removeClass('selected');
                   $(this).addClass('selected');
                                    
                   $panels
                    .hide() // hide ALL the panels
                    .filter(this.hash) // filter down to 'this.hash'
                        .show(); // show only this one
                   
                   return false;
               }).filter(window.location.hash ? '[hash=' + window.location.hash + ']' : ':first').click();
            });
        };
        
        $(document).ready(function () {
            // console.log(window.location.hash);
            
            $('div.tabs').tabs();
        });

