﻿function getRadioValue(el){
	if(!el) return "";
	var radioLength = el.length;
	if(radioLength == undefined) {
		if(el.checked) 
			return el.value;
		else
			return "";
	}
	for(var i = 0; i < radioLength; i++) {
		if(el[i].checked) return el[i].value;
	}
	return "";
} 

/*
<summary>
Add an additional LI to an HTML list. The following variables must be
defined on the referring page: optionalItemCount and optionalItemText
</summary>
<param name="parentId">The ID of the HTML list to which the new list item should be added.</param>
<param name="removeId">The ID of the DIV containing a link to remove the last item in the list.</param>
*/
function AddOptionalItem(parentId, removeId){
	optionalItemCount += 1;
	var NewItem = document.createElement("LI");
	NewItem.innerHTML = eval(optionalItemText);
	document.getElementById(parentId).appendChild(NewItem);
	document.getElementById(removeId).style.display = "block";
}

/*
<summary>
Removes the last LI from an HTML list. The following variables must be
defined on the referring page: optionalItemCount and optionalItemText
</summary>
<param name="parentId">The ID of the HTML list from which the new list item should be removed.</param>
<param name="removeId">The ID of the DIV containing a link to remove the last item in the list.</param>
*/
function RemoveOptionalItem(parentId, removeId){
	var parentElement = document.getElementById(parentId);
	if (parentElement.hasChildNodes()) {
		var oChildNode = parentElement.lastChild;
		parentElement.removeChild(oChildNode);
		optionalItemCount = optionalItemCount - 1;	
	} 
	if (!parentElement.hasChildNodes()) {
		document.getElementById(removeId).style.display = "none";
	}
}

