/*
 * This script is used to validate a check box within a form.
 *
 * Thomas Nicolosi Red Bus Corporation  http://www.redbuscorp.com
 * thomas@redbuscorp.com
 *
 * Rev. 1.0.0.0 5/6/2008
 *
 * The function validateCheckBox is passed the HTML name attribute
 * of the check box that is required.
 * Each check box is retrieved and stored in the Array theCheckBoxes.
 * We then loop through the array until a checked check box is found.
 * The function returns "true" if any check box has been checked.
 *
 */

function validateCheckBox(checkBoxName){
  if (!document.getElementsByName) {
    return false;
  }
  //Get the check boxes.
  var theCheckBoxes = document.getElementsByName(checkBoxName);

  //Check to see if theCheckBoxes array has any members
  if (theCheckBoxes.length < 1) {
    return false;
  }
  
  //Loop through the check boxes and convert isValid to true if any are checked.
  var count;
  var aCheckBox;
  var isValid = false;
  for (count = 0 ; count < theCheckBoxes.length; count++){
     aCheckBox = theCheckBoxes[count];
     if (aCheckBox.checked) {
       isValid = true;
       break;
     } else {
       continue;
     }
  }
  return isValid;
}
