function toggleSelect(selectbutton, name, formName) {
  // required selectbutton: you can pass any object that will function as a toggle
  // required name: name of the the group of checkboxes that needs to be toggled (default=names:list
  // optional initialState: initial state of the group. (default=false)
  // optional formName: name of the form in which the boxes resnamee, use this if there are more
  //   forms on the page with boxes with the same name

  // create and use a property on the button itself so you don't have to 
  // use a global variable and we can have as much groups on a page as we like.
  selectbutton.isSelected = ! selectbutton.isSelected;
  if (formName == null) {
     checkboxes = document.getElementsByName(name)
     for (i = 0; i < checkboxes.length; i++)
       checkboxes[i].checked = selectbutton.isSelected;
  } else {
     for (i = 0; i < document.forms[formName].elements.length; i++)
       if (document.forms[formName].elements[i].name == name) 
          document.forms[formName].elements[i].checked = selectbutton.isSelected;
  }
}
