function insertTab(e, oInput)
	{
	if (e != null)
		{
		if (oInput.selectionStart)
			{ insertTabMoz(e, oInput); }
		else
			{ insertTabIE(e, oInput); }
		}
	return true;
	}
function insertTabMoz(e, oInput)
	{
	if (e.keyCode==9)
		{
		e.preventDefault();
		var sInput = oInput.value;
		var iLeft = oInput.selectionStart;
		var iRight = oInput.selectionEnd;
		var sLeft = sInput.slice(0, iLeft);
		var sRight = sInput.slice(iRight, sInput.length);
		sInput = sLeft + "\t" + sRight;
		oInput.value = sInput;
		oInput.setSelectionRange( iLeft+1 , iLeft+1);
		e.stopPropagation();
		}
	}
function insertTabIE(e, oInput)
	{
	if (e.srcElement)
		{
		if (e.keyCode == 9)
			{
			if (document.selection != null)
				{
				document.selection.createRange().text = '\t';
				e.returnValue = false;
				}
			else
				{ e.srcElement.value += '    '; }
			}
		}
	}




function preventEnter(e, oInput)
	{
	if (e.keyCode == 13)
		{ return false; }
	else
		{ return true; }
	}








function checkValueLength(e, oInput, maxLength)
	{
	var key, keychar;
	if (window.event)
		{ key = window.event.keyCode; }
	else if (e)
		{ key = e.which; }
	else
	   { return true; }

	/* for keycodes: http://www.cambiaresearch.com/cambia3/snippets/javascript/reference/javascript_charcodes.aspx */
	/* these are control keys so they shouldn't raise the pop-up alert because they've probably been used for EDITING the content */
	var bShowAlert = true;
	var aKeys = new Array(8,16,17,18,19,20,27,33,34,35,36,37,38,39,40,91,92,93,112,113,114,115,116,117,118,119,120,121,122,123,144,145)
	for (var ii=0; ii < aKeys.length; ii++)
		{
		if (key == aKeys[ii])
			{bShowAlert = false};
		}

	var oCounter = document.getElementById(oInput.id + "__length");
	var iLength = (oInput.value.length);
	var iLengthRemaining = (maxLength - iLength);

	//oCounter.value = iLengthRemaining;
	oCounter.innerHTML = iLengthRemaining;
	if (iLengthRemaining < 0)
		{
		oCounter.style.color = "#bb0000";
		oCounter.style.fontWeight = "bold";
		}
	else
		{
		oCounter.style.color = "#000000";
		oCounter.style.fontWeight = "normal";
		}

	if ((bShowAlert == true) && (iLengthRemaining < 0))
		{
		if (confirm("You have reached the maximum length allowed for this input (" + maxLength + " character" + ((maxLength > 1) ? "s" : "") + ").\nClick \"OK\" to continue, or \"Cancel\" to trim the entry to the maximum length.") == false)
			{
			oInput.value = oInput.value.substring(0, maxLength);
			//oCounter.value = 0;
			oCounter.innerHTML = 0;
			oCounter.style.color = "#000000";
			oCounter.style.fontWeight = "normal";
			}
		}

	return true;
	}

