function selectIsOptionSelected(oSel, val){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.options.length; i++){
		var oOption = oSel.options[i];
		if (oOption.value == val){
			return oOption.selected;
		}
	}
	return false;
}

function selectHasOptionSelected(oSel){

	if (!oSel) { return false; }

	// alert('selectHasOptionSelected: top');

	if (oSel == null) { return false; }

	if (!oSel) { return false; }

	// alert('selectHasOptionSelected: oSel ok');

	if (oSel.options == null) { return false; }

	// alert('selectHasOptionSelected: oSel.options defined');

	if (oSel.options.length == 0) { return false; }

	// alert('selectHasOptionSelected: oSel.options.length > 1');

	for (var i=0; i < oSel.options.length; i++){
		var oOption = oSel.options[i];
		if (oOption.selected){
			return true;
		}
	}

	// alert('selectHasOptionSelected: top');

	return false;
}

function selectGetOptionSelectedIndex(oSel){

	if (oSel == undefined) { return -1; }

	if (oSel.options == undefined) { return -1; }

	if (oSel.options.length == 0){ return -1; }

	for (var i=0; i < oSel.options.length; i++){
		if (oSel.options[i].selected){
			return i;
		}
	}

	return -1;
}

function selectGetOptionSelectedValue(oSel){

	if (!oSel) { return null; }

	nIndex = selectGetOptionSelectedIndex(oSel);

	// alert('selectGetOptionSelectedValue: nIndex = '+nIndex);

	if (nIndex < 0) {
		return null;
	} else if (nIndex >= oSel.options.length){
		return null;
	} else {

		// alert('selectGetOptionSelectedValue: val = '+oSel.options[nIndex].value);

		return oSel.options[nIndex].value;
	}

}

function selectOptionsAllSelected(oSel){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		oSel.options[i].selected = true;
	}
	
	return true;
}

function selectOptionsNoneSelected(oSel){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		oSel.options[i].selected = false;
	}
	
	return true;
}

function selectSetSelectedWithValue(oSel, sVal){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		oSel.options[i].selected = (oSel.options[i].value == sVal) ? true : false;
	}
	
	return true;

}

function selectRemoveOptionAtIndex(oSel, nIndex){

	if (!oSel) { return false; }
	
	if (!oSel.options) { return false; }

	oSel.options[nIndex] = null;
	
	return true;
}

function selectRemoveOptionWithValue(oSel, sVal){

	if (!oSel) { return false; }

	for (var i = oSel.length - 1; i >=0; i--){
		if (oSel.options[i].value == sVal){
			oSel.options[i] = null;
		}
	}
	
	return true;
}

function selectRemoveOptionAll(oSel){

	if (!oSel) { return false; }

	for (var i = oSel.length - 1; i >=0; i--){
		oSel.options[i] = null;
	}
	
	return true;
}

function selectOptionAdd(oSel, sVal, sTxt){

	if (!oSel) { return false; }
	
	var nIndexNew = oSel.options.length;
	oSel.options[nIndexNew] = new Option(sTxt, sVal);
	
	return true;
}

function selectDisableOptionWithValue(oSel, sVal){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		var oOption = oSel.options[i];
		if (oOption.value == sVal){
			selectDisableOptionAtIndex(oSel, i);
		}
	}
	
	return true;
}

function selectEnableOptionWithValue(oSel, sVal){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		var oOption = oSel.options[i];
		if (oOption.value == sVal){
			selectEnableOptionAtIndex(oSel, i);
		}
	}
	
	return true;
}

function selectEnableOptionsAll(oSel){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		selectEnableOptionAtIndex(oSel, i);
	}
	
	return true;
}

function selectDisableOptionsAll(oSel){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		selectDisableOptionAtIndex(oSel, i);
	}
	
	return true;
}

function selectDisableOptionAtIndex(oSel, nIndex){
	oSel.options[nIndex].disabled = true;
	return true;
}
function selectEnableOptionAtIndex(oSel, nIndex){
	oSel.options[nIndex].disabled = false;
	return true;
}

function selectSetValueSelected(oSel, sVal){

	if (!oSel) { return false; }

	for (var i = 0; i < oSel.length; i++){
		if (oSel.options[i].value == sVal){
			oSel.options[i].selected = true;
		}
	}
	
	return true;
	
}