var selectCache = new Object();
var jsPRC;

initSelectCache();

function getOptions(which){
	if(selectCache[which] == null){
		loadSelectCache(which);
	}
	var options = "";
	for(x in selectCache[which]){
		options += '<option value="' + x + '">' + selectCache[which][x] + '</option>';
	}
	return options;
}

function returnSelectValue(which, name){
	for (var value in selectCache[which]){
		if (selectCache[which][value]==name){
			return value
		}
	}
	return null; 
}

function getOptionText(which, val){
	if(val != ""){
		if(selectCache[which] == null){
			loadSelectCache(which);
		}
		if(selectCache[which] != null){
			return selectCache[which][''+val];
		} else {
			return "";
		}
	} else {
		return "";
	}
}

function initSelectCache() {
	selectCache = new Object();
	var jsXSL = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
	jsXSL.async = false;
	jsXSL.load("/xml/TransformSelect.xml");

	var jsTMP = new ActiveXObject("Msxml2.XSLTemplate");
	jsTMP.stylesheet = jsXSL;
	
	jsPRC = jsTMP.createProcessor();
}

function loadSelectCache(which){
	var xmldoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
	xmldoc.async = false;

	if(which == null || which == ""){
		initSelectCache();
		xmldoc.load("/forms_util/selectxml.aspx");
	} else {
		xmldoc.load("/forms_util/selectxml.aspx?x=" + which);
	}

	jsPRC.input = xmldoc;
	jsPRC.transform();
	eval(jsPRC.output);
}