// Select Checkbox By Clicking on the name or checkbox; submit where appropriate
function select_radio_button(radio_button_name, radio_button_value, from_link){
	
	// Get DOM info on all radio buttons of name == 'radio_button_name'
	var radio_button_name_info	= document.getElementsByName(radio_button_name);
	
	// Get name of form that radio button is a part of and the number of associated radio buttons
	var FormName = GetFormName(radio_button_name);
	var NumberOfRadioButtons = FormName[radio_button_name].length;
	
	// Loop through all Radio Buttons of associated 'radio_button_name'
	for(i=0; i<NumberOfRadioButtons; i++){
		
		// Make sure Radio Button is not disabled
		if(radio_button_name_info[i].disabled != true){
			
			// Get DOM info on CurrentRadioButtonValue
			var CurrentRadioButtonValue = radio_button_name_info[i].value;
			
			// Determine current RadioButtonText value from radio_button_name and CurrentRadioButtonValue
			var RadioButtonText	=	radio_button_name.toLowerCase()+"_"+CurrentRadioButtonValue.toLowerCase()+"_title";
			var intIndexOfMatch = radio_button_value.indexOf(" ");
			
			// Loop through number of occurances of " " in RadioButtonText and replace with "_"
			while (intIndexOfMatch != -1){
				RadioButtonText = RadioButtonText.replace( " ", "_" );	// Replace " " with "_"
				intIndexOfMatch = RadioButtonText.indexOf(" ");			// Get the index of any next matching substring [" "].		
			}
			
			// Get DOM info on RadioButtonText
			var RadioButtonText_info = document.getElementById(RadioButtonText);
			
			// Check to see if current radio button element or accompanying text was clicked
			if(radio_button_name_info[i].value == radio_button_value){
				radio_button_name_info[i].checked = true;
				RadioButtonText_info.style.color = FORM_RADIO_BTN_SELECT_BY_TEXT_ENABLED_COLOR;
			} else{
				radio_button_name_info[i].checked = false;
				RadioButtonText_info.style.color = FORM_RADIO_BTN_SELECT_BY_TEXT_DISABLED_COLOR;
			}
		}
	}
	
	return;
	
}

// Submit Checkbox
function submit_radio_button(radio_button_name){
	
	// Get DOM info on all radio buttons of name == 'radio_button_name'
	var radio_button_name_info	= document.getElementsByName(radio_button_name);
	
	// Make sure Radio Button is not disabled
	if(radio_button_name_info[0].disabled != true){
		
		// Submit Form
		submit_form(radio_button_name);
		
	}
	
	return;
	
}

// Select/Deselect 'Other' Textbox
function ToggleRadioButtonOption(RadioElement, TextElement){
	
	// Gather Info On Radio Buttons of Name 'RadioElement'
	var radio_button_name_info	= document.getElementsByName(RadioElement);
	var FormName				= GetFormName(RadioElement);
	var NumberOfRadioButtons	= FormName[RadioElement].length;
	
	// Loop through all radio buttons of name 'RadioElement'
	for(i=0; i<NumberOfRadioButtons; i++){
		
		// Get value of current 'RadioElement'
		var CurrentRadioButtonValue = radio_button_name_info[i].value.toLowerCase();
		
		// If current 'RadioElement' is of value "other": [continue]
		if(CurrentRadioButtonValue == "other"){
			
			// If current 'RadioElement' is "other" && is "checked": enable 'TextElement' and set focus to 'TextElement'
			if(radio_button_name_info[i].checked == true){
				FormName[TextElement].disabled = false;
				FormName[TextElement].focus();
				FormName[TextElement].style.color = '#000';
			}
			// Else: Disable 'TextElement'
			else{
				//FormName[TextElement].value="";
				FormName[TextElement].disabled = true;
				FormName[TextElement].style.color = '#333';
			}
		}
	}
}

function EnableSubmitButton(RadioElement, ButtonElement){
	
	// Gather Info On Radio Buttons of Name 'RadioElement'
	var radio_button_name_info	= document.getElementsByName(RadioElement);
	var FormName				= GetFormName(RadioElement);
	var NumberOfRadioButtons	= FormName[RadioElement].length;
	
	// If First Radio Button Option Is Selected, Then Enable ButtonElement
	if(radio_button_name_info[0].checked == true){
		FormName[ButtonElement].style.color = "#000";
		FormName[ButtonElement].disabled = false;
	} else{
		FormName[ButtonElement].style.color = "#666";
		FormName[ButtonElement].disabled = true;
	}
	
}

