var dv,im;

function CalcContains()
{
  if (!cp) return false;

  var i, row, pr1;
  pr1 = 0;
  for (i=0;i<cp.length;i++) {
    row = cp[i];
    eval('pr1 += ' + row.cells.item(2).getAttribute('val'));
  }
  cototal1.setAttribute('val', pr1);
  cototal1.removeChild(cototal1.firstChild);
  cototal1.appendChild(document.createTextNode(
    cototal1.getAttribute('val') / 10000));

  return true;
}

function CalcOptions()
{
  if (!op) return false;

  var i, row, pr1;
  pr1 = 0;
  for (i=0;i<op.length;i++) {
    row = op.item(i);
    if (row.cells.item(0).getAttribute('val') == 1) {
      eval('pr1 += ' + row.cells.item(2).getAttribute('val'));
    }
  }
  optotal1.setAttribute('val', pr1);
  optotal1.removeChild(optotal1.firstChild);
  optotal1.appendChild(document.createTextNode(
    optotal1.getAttribute('val') / 10000));
  return true;
}

function CalcSumm()
{
  var i;
  CalcOptions();
  if (total1) {
    var expr = 'i = 0 ';
    if (cototal1) expr = expr + ' + ' + cototal1.getAttribute('val');
    if (optotal1) expr = expr + ' + ' + optotal1.getAttribute('val');
    eval(expr);
    total1.setAttribute('val', i);
    total1.removeChild(total1.firstChild);
    total1.appendChild(document.createTextNode(
      total1.getAttribute('val') / 10000));
  }
}

function OptionClick(obj)
{
  var cell = obj.parentNode;
  var checked = cell.getAttribute('val');
  if (checked == 1)
    checked = 0; else
    checked = 1;
  cell.setAttribute('val', checked);
  cell.parentNode.setAttribute('val', checked);
  CalcSumm();
}

