/* elimina spatiile goale de la inceputul si sfarsitul unui string */
function trim(str) {
	return str.replace(/^\s+|\s+$/g,'');
}

/* limineaza la caractere numerice */
function checkNumber(textBox) {
	while (textBox.value.length > 0 && isNaN(textBox.value)) {
		textBox.value = textBox.value.substring(0, textBox.value.length - 1)
	}
	textBox.value = trim(textBox.value);
/*
	if (textBox.value.length == 0) {
		textBox.value = 0;
	} else {
		textBox.value = parseInt(textBox.value);
	}
*/
}

/* se verifica daca vreun element al formularului este necompletat */
function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	return _isEmpty;
}

function setSelect(listElement, listValue) {
	for (i=0; i < listElement.options.length; i++) {
		if (listElement.options[i].value == listValue) {
			listElement.selectedIndex = i;
		}
	}
}

