/* adds tab navigation style to page sections
   - Must be wrapped in <div id="maketabs">
   - Section links must have class="tablink"
   - Each section must be in <div class="tabsection">
   - Uses Mootools - mootools-1.2.1-core.js and mootools-plugins.js
*/

window.addEvent('domready', function() {
  // change the class, so style from tabs.css is applied
  $('maketabs').className = "tabs";
 
  // add onclick behavior to links
  $$('.tablink').addEvent('click', function() { 
    // hide all sections
    $$('.tabsection').fade('out');
    $$('.tablink').removeClass('current');

    // show this section
    $(this.id + 'Tab').fade('in');
    this.addClass('current');

    return false;
  });

  // fix formatting on two-line tabs
  $$('.tablink').each(function(myItem) { if (myItem.get('html').match("<br>")) { myItem.addClass('twoline'); } });
  
  // hide all sections
  $$('.tabsection').fade('hide');
  $$('.tablink').removeClass('current');
  
  // show the first section by default
  var firstTab = $$('.tabsection')[0];
  $(firstTab).fade('in');
  $(firstTab.id.replace("Tab", "")).addClass('current');
  
  // fix page dimensions for IE6
  setContentDims();
});
