
function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

	function storeCaret (textEl)
{	if (textEl.createTextRange) 
	{	textEl.caretPos = document.selection.createRange().duplicate();
	}
}

function insertAtCaret (textEl, text)
{	if (textEl.createTextRange && textEl.caretPos)
	{	var caretPos = textEl.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	}
	else
	{	textEl.value  = text;
	}
	textEl.focus();
}
