function inputInsertText(theInput, theText) {
	//IE support
	if (document.selection) {
		theInput.focus();
		sel = document.selection.createRange();
		sel.text = theText;
	}
	
	//MOZILLA/NETSCAPE support
	else if (theInput.selectionStart || theInput.selectionStart == "0") {
		var startPos     = theInput.selectionStart;
		var endPos       = theInput.selectionEnd;
		var currentValue = theInput.value;
		
		theInput.value =
			currentValue.substring(0     , startPos             ) +
			theText +
			currentValue.substring(endPos, theInput.value.length);
	}
	
	//support for other browsers
	else {
		theInput.value += theText;
	}
}

function trimInputValue(theInput) {
	theInput.value = trimString(theInput.value);
}

function queryFilledIn(theInput, objectName) {
	if(theInput.value == '') {
		window.alert('Vul ook een '+objectName+' in!');
		theInput.focus();
		return false;
	}
	return true;
}

function trimString(value) {
	var skipAtEnd = 0;
	for(var i=value.length-1;i>=0;i--, skipAtEnd++)
	if(value.charAt(i) != ' '  &&
	   value.charAt(i) != '\t' &&
	   value.charAt(i) != '\r' &&
	   value.charAt(i) != '\n')
		break;
	
	var newValue = '';
	var i=0;
	while(i<value.length-skipAtEnd && (
		value.charAt(i) == ' '  ||
		value.charAt(i) == '\t' ||
		value.charAt(i) == '\r' ||
		value.charAt(i) == '\n'))
			i++;
	
	while(i<value.length-skipAtEnd) {
		newValue += value.charAt(i);
		i++;
	}
	
	return newValue;
}
