// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

/*
 * check_all_checkboxes() accepts a form object, a pattern and a value.
 * It sets the 'checked' attribute of all checkboxes matching the pattern
 * to the value.
 */
function check_all_checkboxes(form, pattern, value)
{
  var count = 0;

  if (form != null)
  {
    for(i=0; i < form.elements.length; i++)
    {
      var item = form.elements[i];

      if (item.type == "checkbox" && item.name.search(pattern) >= 0)
      {
        item.checked = value;
      }
    }
  }

  return count;
}

