
function addOptgroup(oSelect, oData) {
	retStr = "";
	var returnValue = null;
	var i = 0;

	if (formName) {
		oSelectObj = eval("document.forms[formName]." + oSelect);
		oSourceObj = eval("sourceOpt[oData]");

		if (!oSelectObj) {
			oSelectObj = document.getElementById(oSelect);
		}

		if (oSelectObj) {
			for (a=0; a < oSourceObj.length; a++) {
				retStr += oSourceObj[a][0] + "\n";
				for (aa=0; aa < oSourceObj[a][1].length; aa++) {
					retStr += "\t" + oSourceObj[a][1][aa] + "\n";
				}
			}

			if (oSelect && oData) {
				fOption = document.createElement('OPTION');
				oSelectObj.appendChild(fOption);
				fOption.text = "Select One...";
				fOption.value = "";
				for (b=0;b < oSourceObj.length; b++) {
					oOptgroup = document.createElement('OPTGROUP');
					oOptgroup.label = oSourceObj[b][0];
					for(bb = 0; bb < oSourceObj[b][1].length; bb++) {
						oOption = document.createElement('OPTION');
						oOptgroup.appendChild(oOption);
						oOption.text = oSourceObj[b][1][bb][0];
						oOption.value = oSourceObj[b][1][bb][1];
						returnValue = oOptgroup;
					}
					oSelectObj.appendChild(oOptgroup);
				}
			}
	
			return returnValue;
		}
	}else{
		alert("The formName variable has not been defined");
		return false;
	}
}

function removeOptgroup(oSelect) {
	oSelectObj = eval("document.forms[formName]." + oSelect);

	try {
		nodeArray = oSelectObj.childNodes;
		while (nodeArray.length > 0) {
			for (n=0; n < nodeArray.length; n++) {
				oSelectObj.removeChild(nodeArray[n]);
			}
		}
	/*
		optgroupArray = oSelectObj.getElementsByTagName("OPTGROUP");
		for (o=0; o < optgroupArray.length; o++) {
			optgroupObj = optgroupArray[o];
			optgroupObj.removeNode(true);
		}

		while (oSelectObj.getElementsByTagName("OPTGROUP").length > 0) {
			for (oo=0; oo < optgroupArray.length; oo++) {
				optgroupObj = optgroupArray[oo];
				optgroupObj.removeNode(true);
			}
		}
	*/
	}
	catch(x) {}
}
