
	// takes a database array { value:v, text:t}
	// returns a function which will build a selection
	// sdb : name -> array { value, text }
	//
	function mkSelector(sdb, ID, description){
	return function (pChoice) {
		var chooser = document.getElementById(ID);
		chooser.options.length = 0;
		
		//alert("pChoice = "+pChoice);
		var db      = sdb[pChoice];
		//db = sdb["leaflets DL"];

		// insert default 1st item
		chooser.options[0] = new Option("Choose a " + description , "", true, false);
		if(pChoice != ""){
			for(var i=0; i< db.length; i++){
				chooser.options[i+1] = new Option(db[i].text, db[i].value);
			}
		}
	       }
	}


	function mkSelection(db, ID, description, selection){
		var chooser = document.getElementById(ID);
		if(!chooser) alert("no chooser element "+ID);
		chooser.options.length = 0;
		
		// insert default 1st item
		description = description?" "+description:'';
		chooser.options[0] = new Option("Choose" + description , "", true, false);
		var isSelected = false;

		for(var i=0; i< db.length; i++){
			var r = db[i];
			var v = db[i].value;
			isSelected = (v == selection) ? true : false; 
			chooser.options[i+1] = 
			new Option(db[i].text, db[i].value, false, isSelected);
		}
	}

	

