// ----------------------------------------------------------------------------------------------------------------------------------------
// field functions
// ----------------------------------------------------------------------------------------------------------------------------------------

function enableField(field) { el(field).disabled=false; }

// ----------------------------------------------------------------------------------------------------------------------------------------

function disableField(field) { el(field).disabled=true; }

// ----------------------------------------------------------------------------------------------------------------------------------------

function enableDisableField(field,state) { el(field).disabled=state; }

// ----------------------------------------------------------------------------------------------------------------------------------------

function enableDisableGroup(formName,groupName,state) {
	for (var i=0; i<formName.elements.length; i++) {
		if (formName.elements[i].name == groupName) { formName.elements[i].disabled = state; }
	}
}

// ----------------------------------------------------------------------------------------------------------------------------------------

function enableGroup(formName,groupName) { enableDisableGroup(formName,groupName,true); }

// ----------------------------------------------------------------------------------------------------------------------------------------

function disableGroup(formName,groupName) { enableDisableGroup(formName,groupName,false); }

// ----------------------------------------------------------------------------------------------------------------------------------------

function changeObjVisibility(field,visiblestate) { el(field).style.visibility=visiblestate; }

// ----------------------------------------------------------------------------------------------------------------------------------------

function field2UC(field) { convert2UpperCase(field); }

// ----------------------------------------------------------------------------------------------------------------------------------------

function field2LC(field) { convert2LowerCase(field); }

// ----------------------------------------------------------------------------------------------------------------------------------------

function resetField(field) { field.value=''; }

// ----------------------------------------------------------------------------------------------------------------------------------------

function convert2LowerCase(field) { field.value=trim(field.value.toLowerCase()); }

// ----------------------------------------------------------------------------------------------------------------------------------------

function convert2UpperCase(field) { field.value=trim(field.value.toUpperCase()); }

// ----------------------------------------------------------------------------------------------------------------------------------------

function setFieldToUpperCase(){ for(var i=0;i<arguments.length;i++) { arguments[i].value = trim(arguments[i].value.toUpperCase()); } }

// ----------------------------------------------------------------------------------------------------------------------------------------

function setFieldVisible(field) {
	var obj=el(field);
	obj.style.visibility='visible';
	obj.style.display='inline';
}

// ----------------------------------------------------------------------------------------------------------------------------------------

function setFieldInvisible(field) {
	var obj=el(htmlObj);
	obj.style.visibility='hidden';
	obj.style.display='none';
}

// ----------------------------------------------------------------------------------------------------------------------------------------

function showDIV(divObj) {
	if (divObj.style!=undefined && divObj!=null) {
		if (divObj.style.visibility!='visible') {
			divObj.style.visibility='visible';
			divObj.style.display='inline';
		}
	}
}

// ----------------------------------------------------------------------------------------------------------------------------------------

function hideDIV(divObj) {
	if (divObj.style!=undefined && divObj!=null) {
		if (divObj.style.visibility!='hidden') {
			divObj.style.visibility='hidden';
			divObj.style.display='none';
		}
	}
}

// ----------------------------------------------------------------------------------------------------------------------------------------

function insertAtCursor(obj, value) {
	//IE support
	if (document.selection) {
		obj.focus();

		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		sel = document.selection.createRange();
		sel.text = value;
	}
	else if (obj.selectionStart || obj.selectionStart == '0') {
		//Mozilla/Firefox/Netscape 7+ support
		//Here we get the start and end points of the
		//selection. Then we create substrings up to the
		//start of the selection and from the end point
		//of the selection to the end of the field value.
		//Then we concatenate the first substring, myValue,
		//and the second substring to get the new value.
		var startPos = obj.selectionStart;
		var endPos = obj.selectionEnd;
		obj.value = obj.value.substring(0, startPos)+ value+ obj.value.substring(endPos, obj.value.length);
	} else {
		obj.value += value;
	}
}

// ----------------------------------------------------------------------------------------------------------------------------------------

function getCheckedValue(radioObj) {
	if(!radioObj) return "";

	var radioLength = radioObj.length;

	if(radioLength == undefined) {
		if(radioObj.checked) return radioObj.value;
		else return "";
	}

	for (var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) { return radioObj[i].value; }
	}

	return "";
}

// ----------------------------------------------------------------------------------------------------------------------------------------

function getCheckedIndex(radioObj) {
	if(!radioObj) return "";

	var radioLength = radioObj.length;

	if(radioLength == undefined) {
		if(radioObj.checked) return 0;
		else return "";
	}

	for (var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) { return i; }
	}

	return "";
}

// ----------------------------------------------------------------------------------------------------------------------------------------
