/*  ==============================================================
    RoundedBox class
    ============================================================== */

var RoundedBoxCount = 0;

function RoundedBox(o) {
  this.parentElement = $('body')[0];
  this.contentElement = null;
  this.wrapperElement = null;
  var rCount = RoundedBoxCount;
  this.idC = 'rBoxContent'+rCount;
  this.idW = 'rBoxWrapper'+rCount;
  this.idT = 'rBoxTop'+rCount;
  this.idB = 'rBoxBottom'+rCount;
  this.ul = 'ul40green.png';
  this.ur = 'ur40green.png';
  this.ll = 'll40green.png';
  this.lr = 'lr40green.png';
  this.type = null;
  this.green40 = {
      bgColor:'#5CCDC9', height:'20px',
      ul:'ul40green.png', ur:'ur40green.png',
      ll:'ll40green.png', lr:'lr40green.png'
  };
  this.white40 = {
      bgColor:'#FFFFFF', height:'20px',
      ul:'ul40white.png', ur:'ur40white.png',
      ll:'ll40white.png', lr:'lr40white.png'
  };
  this.init(o);
}

RoundedBox.prototype.init = function(o) {
  var _this = this;
  this.type = this.white40;
  if(o) {
    if (o.type=='white40') {this.type=this.white40;};
    if (o.type=='green40') {this.type=this.green40;};
    if (o.parentElement) {this.parentElement=o.parentElement;};
  }
  this.html = ''
    +'<div id="'+this.idW+'" class="rBoxWrapper" style="display:none;">'
    +'<div id="'+this.idT+'" class="rBoxTop"><img src="/images/'+this.type.ul+'" alt="ul"></div>'
    +'<div id="'+this.idC+'" class="rBoxContent"></div>'
    +'<div id="'+this.idB+'" class="rBoxBottom"><img src="/images/'+this.type.ll+'" alt="ll"></div>'
    +'</div>'
    +'';
  this.visible = false;
  RoundedBoxCount++;
  $(this.parentElement).append(this.html);
  this.contentElement = $('#'+this.idC)[0];
  this.wrapperElement = $('#'+this.idW)[0];
  this.t = $('#'+this.idT)[0];
  this.b = $('#'+this.idB)[0];
  $(this.t).css('background',_this.type.bgColor+' url("/images/'+this.type.ur+'") no-repeat scroll right');
  $(this.b).css('background',_this.type.bgColor+' url("/images/'+this.type.lr+'") no-repeat scroll right');
  $(this.contentElement).css('background',_this.type.bgColor);
};

RoundedBox.prototype.show = function() {
  $(this.wrapperElement).show();
  this.visible=true;
};
RoundedBox.prototype.hide = function() {
  $(this.wrapperElement).hide();
  this.visible=false;
};

RoundedBox.prototype.setContent = function(html) {
  $(this.contentElement).html(html);
};

