function clsCart(options, data) {
  if (!$(options.container)) return false;

  this.data = data || null;
  
  this.control = { container: options.container };
  this.controlBind(options.container);
  
  this.setData();
}

clsCart.prototype.setData = function() {
  if (!this.data) return false;

  this.show();

  iProduct = 0;
  iPrice = 0;
  
  rCompany = $A([ ]);
  
  $H(this.data).each(function(item) {
    if (rCompany.indexOf(item.value.company_id) < 0) { rCompany.push(item.value.company_id); }
    iProduct++;
    iPrice += item.value.price;
  });

  this.control.product.set(iProduct);
  this.control.company.set(rCompany.size());
  this.control.price.set(iPrice);
}

clsCart.prototype.addData = function(data) {
  this.control.title.load();
  if (!this.data) { this.data = data; } else { Object.extend(this.data, data); }
  this.setData();
  this.control.title.done();
}

clsCart.prototype.remData = function(data) {

}

clsCart.prototype.ctrlTitle = function(element, options) {
  class_ = this;

  return {
    initialize: function() {
      this.control = { img: element.getElementsByTagName('img')[0] };
    },
    load: function() {
      this.control.img.src = '/global/images/partsearch.v2/ico/loading_16x16.gif';
    },
    done: function() {
      this.control.img.src = '/global/images/partsearch.v2/ico/cart_16x16.png';
    },
    class_: class_
  }
}

clsCart.prototype.ctrlLabel = function(element, options) {
  class_ = this;

  return {
    initialize: function() {
      this.set(0);
    },
    set: function(value) {
      this.innerHTML = value;
    },
    class_: class_
  }
}

clsCart.prototype.show = function() {
  this.control.container.style.visibility = 'visible';
}

clsCart.prototype.controlBind = function(holder) {
  class_ = this;

  bind = {
    holderTitle: { label: 'title', extend: function(item){return class_.ctrlTitle(item, { })} },
    labelProduct: { label: 'product', extend: function(item){return class_.ctrlLabel(item, { })} },
    labelCompany: { label: 'company', extend: function(item){return class_.ctrlLabel(item, { })} },
    labelPrice: { label: 'price', extend: function(item){return class_.ctrlLabel(item, { })} }
  }
  
  rElement = [ ];
  $A(holder.getElementsByTagName('div')).each ( function(item) { rElement.push(item); } )
  $A(holder.getElementsByTagName('span')).each ( function(item) { rElement.push(item); } )
  
  $A(rElement).each (
    function(item) {
      if(structure = bind[item.getAttribute('title')]) {
        class_.control[structure.label] = $(item);
        if(structure.extend) Object.extend(item, structure.extend(item)).initialize();
      }
    }
  );
}
