﻿;(function($){
    $.fn.extend({ 
        currenttab:'nofing',
        tabify: function() {

            return this.each(function() {

                var obj = $(this);
                
                var headings = $('a', obj);
                var currenttab=null
                var first=true
                
                headings.each(function() {
                  if(first!=true) {
                    $($(this).attr('href')).hide();
                  }else{
                    currenttab=$(this)
                    $($(this).attr('href')).show()
                    $(this).addClass("sel");
                    first=false;
                  }
                });
                
                headings.click(function() {
                  if(currenttab[0]==$(this)[0])return false;
                  currenttab.removeClass("sel");
                  $(this).addClass("sel");
                   
                  //if(currenttab) {
                    $(currenttab.attr('href')).slideUp('slow');
                    $($(this).attr('href')).slideDown('slow');
                  //} else {
                    //$($(this).attr('href')).slideDown('slow');
                  //}
                                  

                  //And display the clicked tab
                  currenttab = $(this);
                  return false;
                });
            });
        }
    });
})(jQuery);

