var ALVEOS = {
  load_all: function () {
    ALVEOS.load_component(ALVEOS.Amplifier);
    
    ALVEOS.load_component(ALVEOS.Tools);
    
    ALVEOS.load_component(ALVEOS.Charts);
    
    ALVEOS.load_component(ALVEOS.FormController);
    
    ALVEOS.load_component(ALVEOS.BonzaiController);
    
    ALVEOS.load_component(ALVEOS.BambooGridController);
    
    ALVEOS.load_component(ALVEOS.BambooListController);
    
    ALVEOS.load_component(ALVEOS.TabascoController);
    
    ALVEOS.load_component(ALVEOS.ChronovisorController);
    
    ALVEOS.load_component(ALVEOS.Sectors);
  },
  
  load_component: function(component){ if(typeof(component) === 'function'){ component(); } }
};

ALVEOS.StringBuilder = function(){
  var content = [],
      position = 0;
  
  this.add = function(value) { content[position++] = value; };
  this.get = function() { return content.join(''); };
};

ALVEOS.is_d = function(content){ return (typeof(content) !== 'undefined'); };

ALVEOS.merge_hash = function(options, default_options){ 
  if(!ALVEOS.is_d(options)){ return default_options; }
  
  jQuery.each(default_options, function(key, value){
    if(!ALVEOS.is_d(options[key])){ options[key] = value; }
  });
  
  return options;
};

ALVEOS.trigger = function(element_id, event_name){ $j('#' + element_id).trigger(event_name); };

$j(document).ready( function() { ALVEOS.load_all(); });


ALVEOS.Sectors = function(){
  var sectors = ['Admin', 'Ebook', 'Showcase'];
      
  $j.each(sectors, function(){ ALVEOS.load_component(ALVEOS.Sectors[this]); });
};


ALVEOS.Sectors.Ebook = function(){
  var self = ALVEOS.Sectors.Ebook;
  
  self.UI().initialize();
};

ALVEOS.Sectors.Ebook.UI = function(){
  var init_ui,
      holder = $j('#window-ebook');
  
  init_ui = function(item){
    var header;
    
    if(holder.length > 0){
      if(holder.find('div.head-organisation').length > 0){
        header = holder.find('div.head-organisation');
        holder.find('#wrapper-ebook').height(holder.innerHeight() - header.outerHeight());
      }
      
      holder.find('#wrapper-ebook').show();
    }
  };
  
  return { initialize: function(){ init_ui(); }};
};