(function($){
	$.fn.utabs = function(options) {
	  var tabContainer$ = $(this);
		var defaults = {
		  activeTab: $(".tab_button:first", tabContainer$),
		  tabIn: null,
		  tabOut: null
  	};  
	 	var opts = $.extend(defaults, options);
    var showTab = function(tabId) {
      $(".tab_panel", tabContainer$).each(function(index) {
        if ($(this).hasClass(tabId)) {
          $(this).show();
          if (opts.tabIn) {
            opts.tabIn.call(this, index);
          }
        }
        else {
          $(this).hide();
            if (opts.tabOut) {
              tabOut.call(this, index);
            }
        }
      });
      
      
    };
    $( ".tab_button", tabContainer$).click(function() {
      activeTabId = $(this).attr("rel");
      $(".tab_button", tabContainer$).removeClass("active");
      $(this).addClass("active");
      showTab(activeTabId);
      return false;
    });
    $(".tab_button", tabContainer$).each(function(index) {
      $(this).attr("rel", "tab" + (index+1));
    });
    
    $(".tab_panel", tabContainer$).each(function(index) {
      $(this).addClass("tab" + (index+1));
    });
    opts.activeTab.click();
  };
})(jQuery);