﻿var InfoBox = Class.create();
InfoBox.prototype = {
  initialize: function(header, content, options){
    this.options = Object.extend({
      sizeType: 2
    }, options);
    this.header = header;
    this.content = content;
  },
  
  getInfoBox: function(){
    this.element = this.getTable();
    var tbody = this.getTableBody();    
    tbody.appendChild(this.getHeaderRow());
    tbody.appendChild(this.getContentRow());
    tbody.appendChild(this.getBottomRow());    
    this.element.appendChild(tbody);
    return this.element;
  },
  
  getBottomRow: function(){
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.className = 'bottom';
    tr.appendChild(td);
    return tr;
  },
  
  getContentRow: function(){
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.className = 'content';
    td.appendChild(this.content);
    tr.appendChild(td);
    return tr;
  },
  
  getHeaderRow: function(){
    var tr = document.createElement('tr');
    var td = document.createElement('td');
    td.className = 'header';
    var h2 = new Element('h2');
    h2.update(this.header);
    td.appendChild(h2);
    tr.appendChild(td);    
    return tr;
  },
  
  getTableBody: function(){
    return document.createElement('tbody');
  },
  
  getTable: function(){
    var table = document.createElement('table');
    table.cellPadding = '0';
    table.cellSpacing = '0';
    table.className = this.getTableClass();
    return table;
  },
  
  getTableClass: function(){
    var result;
    switch(this.options.sizeType){
      case 1:
        result = 'infobox';
        break;
      case 2:
        result = 'infoboxMedium';
        break;
      case 3:
        result = 'infoboxLarge';
        break;
    }
    return result;
  }
}