<!-- -----------------------------------------------------------------
// $Id: RadioChooser.js,v 1.1 1999/01/29 19:49:24 willa Exp $
//
// File:    RadioChooser.js
// Auther:  Willa Zhu,  PMEL/NOAA
// Date:    Jan 26, 1999 (Created)
//
// The RadioChooser object handles RADIO BUTTONS selection.
//
// Argument: (none)
// Methods:
//    click(index) = setClick
//              set radio button at index to be clicked (selected).
//    reset() = resetRadio
// 		reset all the radio buttons to their defaultChecked value.
//    getIndex() = getCheckedIndex
// 		get index of selected radio button
//    getValue() = getCheckedValue
// 		get value of selected radio button
//
// ------------------------------------------------------------------
//
// setClick method for the RadioChooser object.
//              set radio button at index to be clicked (selected).
//
function setClick(index) {
  this.radioBtn[index].click();
}
//
// resetRadio method 
// reset all the radio buttons to their defaultChecked value.
//
function resetRadio() {
  for (var i=0; i < this.radioBtn.length; i++) {
    this.radioBtn[i].checked = this.radioBtn[i].defaultChecked;
  }
}

// getCheckedIndex method for the RadioChooser object.
// get index of selected radio button
//
function getCheckedIndex() {
  for(var i=0; i < this.radioBtn.length; i++) {
    if(this.radioBtn[i].checked) return i;
  }
  return "None";
}

// getCheckedValue method for the RadioChooser object.
// get value of selected radio button
//
function getCheckedValue() {
  for(var i=0; i < this.radioBtn.length; i++) {
    if(this.radioBtn[i].checked) 
      return this.radioBtn[i].value;
  }
  return "None";
}

// RadioChooser Object  constructor
//
function RadioChooser(radio_btn) {
  // properties
  if(radio_btn)
    this.radioBtn=radio_btn;
  else
    alert("Invalid Radio Button name. Please check you HTML file.");


  // methods
  this.getValue = getCheckedValue;
  this.getIndex  = getCheckedIndex;
  this.reset = resetRadio;
  this.click = setClick;
}

// -->
