
function ddD_AddSet(setID, texts, vals) {

	// creates a new data 'set' in a ddData object
	// passed	:	setID		-		Id for set
	//					texts		-		array of text items for dd
	//					vals		-		array of corresponding values for dd
	if (!this.sets[setID]) this.sets[setID] = new Array();
	this.sets[setID]['texts'] = texts;
	this.sets[setID]['vals'] = vals;
	
}

function ddD_populateDD(dropdownID, setID, selectedVal, initRow) {

	// populates a drodown with a given data set from ddData object
	// passed	:	dropdownID		-		id of dropdown on page
	//					setID				-		id of set within ddData to use
	//					selectedVal		-		initial value to select
	//					initRow			-		optional additional first row (array(val,text))
	
	if (dd=document.getElementById(dropdownID)) {
		thisSet = this.sets[setID];
		dd.options.length = 0;
		s=0;
		if (initRow) { s=1; dd.options[0] = new Option(initRow[0], initRow[1]); };
		if (thisSet) {
			for (i=s;i<(s+thisSet['texts'].length);i++) {
				dd.options[i] = new Option(thisSet['texts'][i-s], thisSet['vals'][i-s], '', (thisSet['vals'][i-s]==selectedVal) );
			}
		}
	}
	
}


function ddData() {

	// Creates a new ddData object
	this.sets = new Array();
	this.addSet = ddD_AddSet;
	this.populateDD = ddD_populateDD;
	
} 

