
function $(id) {
	return document.getElementById(id);
}

function getSelectedValue(theSelect) {
	return theSelect.options[theSelect.selectedIndex].value;
}

function addOption(theElementAppendTo, theText, theValue) {
	var myOption = document.createElement('option');
	myOption.innerHTML = theText;
	myOption.value = theValue;
	theElementAppendTo.appendChild(myOption);
}

function emptySelect(theSelect) {
	while (theSelect.hasChildNodes()) {
		theSelect.removeChild(theSelect.firstChild);
	}
}

function emptySelectExcludeFirst(theSelect, excludePos) {
	while (theSelect.hasChildNodes()) {
		if (theSelect.length == 1) {
			break;
		}
		theSelect.removeChild(theSelect.lastChild);
	}
}

function addOptionGroup(theElementAppendTo, theLabel) {
	var myOptionGroup = document.createElement('optgroup');
	myOptionGroup.label = theLabel;
	theElementAppendTo.appendChild(myOptionGroup);
	return myOptionGroup;
}

function sendFormTodo(theTodo) {
	$('todo').value = theTodo;
	sendForm();
}

function sendForm() {
	$('form').submit();
}