/**
 * MindCMS 3
 *
 * msTabContainer
 *
 * JS msTabContainer object definition
 *
 * @package CMS3
 * @author Francisc Ungureanu <francisc.ungureanu@mindbench.nl>
 * @copyright Mindbench Active Media B.V.
 * @version $Id: msTabContainer.js 7000 2008-12-18 13:25:26Z fun $
 *
 * Details:
 * 
 * 
 * 
 */

msTabContainer = Class.create(msContainer, {
  xtype: 'tab-container',
  
  tabs: [],
  activeTab: false,
  
  initialize: function ($super, config)
  {     
    $super(config);
  },

  build: function ()
  {
    if(!this.tabs) return;
    var THIS = this;
    //cycles through all the pluings
    this.items.each ( function(item) {
      THIS.addItem(item, THIS.tabs);
      if ( item.isActive ) {
        item.el.addClassName('msr-active-item');
        THIS.isActive = true;
        THIS.activeTab = item;
      }
    });
    
  },
    
  //return the current active tab    
  getActiveTab: function () {
    return this.activeTab;
  },
  
  setActiveTab: function (item) {
    //disables the old active tab if we have one
    if(this.getActiveTab()) {
      this.getActiveTab().el.removeClassName('msr-active-item');
    }
    
    //enableds the new active tab
    item.el.addClassName('msr-active-item');
    this.activeTab = item;
  },
  
  getTabs: function () {
    return this.tabs;
  }
});
