this.SectionManager = Class.create({
  sections: [],
  nextSection: null,
  section: null,
  
  initialize: function()
  {
    SectionManager.openSection = delegate(this, this.openSection);
  },
  
  addSection: function( section )
  {
    this.sections.push( section );
  },
  
  openSection: function( id )
  {
    this.nextSection = this.getSectionById( id );;
    if( !this.nextSection ) return;
    if( this.section )
    {
      this.section.close( delegate( this, this.onCloseSection ) );
    }
    else
    {
      this.openNewSection();
    }
  },
  
  openNewSection: function()
  {
    this.section = this.nextSection;
    this.nextSection = null;
    this.section.open( delegate( this, this.onOpenSection ) );
  },
  
  onOpenSection: function()
  {
    
  },
  
  onCloseSection: function()
  {
    this.section = null;
    if( this.nextSection ) this.openNewSection();
  },
  
  getSectionById: function( id )
  {
    for( i = 0; i < this.sections.length; i ++)
    {
      if( this.sections[i].id == id ) return this.sections[i];
    }
  }
});
