﻿function ToggleCheckboxes(checkbox)
{
  var list = document.getElementsByTagName('input');
  for(var i in list)
  {
    var obj = list[i];
    if(obj && obj.getAttribute && obj.getAttribute('type') == 'checkbox')
    {
      if(obj.name.indexOf('Firm_') == 0)
      {
        obj.checked = checkbox.checked;
      }
    }
  }
}

function CountCheckedCheckboxes()
{
  var result = 0;
  var list = document.getElementsByTagName('input');
  for(var i in list)
  {
    var obj = list[i];
    if(obj && obj.getAttribute && obj.getAttribute('type') == 'checkbox')
    {
      if(obj.name.indexOf('Firm_') == 0)
      {
        if(obj.checked)
        {
          result++;
        }
      }
    }
  }
  return result;
}

function UpdateCheckedCheckboxCount()
{
  var count = CountCheckedCheckboxes();

  var obj = document.getElementById("FirmCount");
  if(obj)
  {
    obj.innerHTML = count.toString();
  }

  obj = document.getElementById("SubmitButton");
  if(obj)
  {
    obj.disabled = (count == 0);
  }
}


