
function selectedValueForRadioButton(radioButtonName) {

   var theRadio = eval("document.forms[0]." + radioButtonName)
   
   if (!theRadio) return -1
   
   //Just in case theres only one item, then it won't be an array!
   if (theRadio.checked) {
        return theRadio.value
   }
      
   for (var i=0; i < theRadio.length; i++) {
        if (theRadio[i].checked) return theRadio[i].value;
   }
   
   return -1;
}

//====================================== Separator ==========================================

function clearRadioButton(radioButtonName) {

   var theRadio = eval("document.forms[0]." + radioButtonName)
   
   //Just in case theres only one item, then it won't be an array!
   if (theRadio.checked) {
        theRadio.checked = false;
        return
   }
      
   for (var i=0; i < theRadio.length; i++) {
        theRadio[i].checked = false
   }
   
   return ;
}

function clearRadioButtonList(radioButtonListName) {

    var elementRef = document.getElementById(radioButtonListName);
    var inputElementArray = elementRef.getElementsByTagName('input');

    for (var i = 0; i < inputElementArray.length; i++) {
        var inputElement = inputElementArray[i];

        inputElement.checked = false;
    }
    return false;
}


//====================================== Separator ==========================================

function toggleRadioButtonEnabledOrDisabled(radioButtonName, enabledOrDisabled) {

   var theRadio = eval("document.forms[0]." + radioButtonName)
   
   //Just in case theres only one item, then it won't be an array!
   if (theRadio.checked) {
        theRadio.disabled = enabledOrDisabled;
        return
   }
      
   for (var i=0; i < theRadio.length; i++) {
        theRadio[i].disabled = enabledOrDisabled;
   }
   
   return ;
}


//====================================== Separator ==========================================

//.NET repeater doesn't support grouping of radio buttons when displayed as a column.
//This function replicates the actions performed when clicking a radio button in a radio group.
function ToggleRadioList(radio_id_list, selected_radio_id) {
    var radio_id_array = radio_id_list.split(',');
    //var sel_rad_id = '<%=selected_radio_id.ClientID%>';
    var sel_rad_id = selected_radio_id
    
  for (var i = 0; i < radio_id_array.length; i++) {
      //alert('array- \n' + radio_id_array[i] + ' \n\nselected- \n' + sel_rad_id);
      if (radio_id_array[i] == selected_radio_id)
          document.getElementById(radio_id_array[i]).checked = true;
      else {
          var elem = document.getElementById(radio_id_array[i]);
          if(elem) //check to make sure the radio exists first.
            document.getElementById(radio_id_array[i]).checked = false;
      }
  }

}//End SetRadioList()   
