  // Written by Sean Treadway 2006 sean@treadway.info
  // Free Beer and Free Speech - the best license of all
  // init 
  // TabControl('tab_control', { current: 'a_page' });
  // tab html
  /*
	<div id="tab_control">
	  <ul class="tabs"><li><a href="#a_page">Page 1</a></li></ul>
	  <div id="a_page" class="tab_page">
	  ...
	  </div>
	</div>
  */

  TabControl = function(control_id, options) {
    var id = "#" + control_id;
    $$(id+' ul.tabs li a').each(function(a) {
      var page = a.getAttribute('href').match(/[-_\w]+$/i)[0];

      if (page != options['current']) { $(page).hide() } 
      else { $(a.parentNode).addClassName('active') }

      Event.observe(a, 'click', function(e) {
        $$(id+' ul.tabs li.active').each(function(e) { e.removeClassName('active'); })
        $$(id+' .tab_page[id!='+page+']').each(function(e) { e.hide() });
        $(a.parentNode).addClassName('active');
        //$(page).show();
		Effect.BlindDown($(page),{ duration: 0.5});
        Event.stop(e);
      });
    });
  }
  
  TabControlMulti = function(control_id, options, subLevel) {
    var id = "#" + control_id;
    $$(id+' ul.tabs li a').each(function(a) {	
	
	
	 var page = a.getAttribute('href').match(/[-_\w]+$/i)[0];	 
		
	  if (page != options['current'] && $(page).hasClassName(subLevel)) { $(page).hide() } 
	  else { $(a.parentNode).addClassName('active');$(page).show() }	  
	  if(!$(a).hasClassName(subLevel)) return;
	  Event.observe(a, 'click', function(e) {
		
			$$(id+' ul.tabs li.active').each(function(e) { e.removeClassName('active'); })
			$$(id+' .tab_page[id!='+page+']').each(function(e) { e.hide() });
			$(a.parentNode).addClassName('active');
			//$(page).show();
			Effect.BlindDown($(page),{ duration: 0.5});
			Event.stop(e);
		
		
	  });
	  
	  console.debug(options['current'], "curent");
		$(options['current']).show();
    });
  }