// versionCode 20050110_2317

function getSelect(id) {
	return document.getElementById(id);
}

function getSelectedIndex(id) {
	var sel = getSelect(id);
	return sel.selectedIndex;
}

function getSelectedValue(id) {
	var sel = getSelect(id);
	var selIdx = getSelectedIndex(id);
	return sel[selIdx].value;
}

function getSelectedText(id) {
	var sel = getSelect(id);
	var selIdx = getSelectedIndex(id);
	return sel[selIdx].text;
}

function selectValue(id, value) {
	var sel = getSelect(id);
	if (!sel) return;
	var optionCount = getOptionCount(id);
	for (var ii=0;ii<optionCount;ii++) {
		var oneVal = sel.options[ii].value;
		if (oneVal == value) {
			sel.options[ii].selected = true;
			return;
		}
	}
}

function selectText(id, text) {
	var sel = getSelect(id);
	if (!sel) return;
	var optionCount = getOptionCount(id);
	for (var ii=0;ii<optionCount;ii++) {
		var oneText = sel.options[ii].text;
		if (oneText == text) {
			sel.options[ii].selected = true;
			return;
		}
	}
}


function getOptionCount(id) {
	var sel = getSelect(id);
	if (sel.options) {
		return sel.options.length;
	} else {
		return 0;
	}
}

/*
verion:

20050110_2317:
first version

*/