//************************
//Written by: Andre Nadler
//************************
function Capitalize(pText)
{
	var iLen, iChar
	var sChar, sPrevChar, sText

	iLen = pText.value.length - 1;
	sChar = pText.value.charAt(0);
	sText = sChar.toUpperCase();

	for (iChar = 1; iChar <= iLen; iChar++)
	{
		sChar = pText.value.charAt(iChar);
		if (sPrevChar == " ")
			sText = sText + sChar.toUpperCase();
		else
			if (sChar == "'")
				sText = sText + "`";
			else
				sText = sText + sChar;
		sPrevChar = sChar;
	}
	sText = SwapThe(sText);
	pText.value = sText;
}
function SwapThe(sNewText)
{
	var iLen
	var sText
	iLen = sNewText.length;

	sText = sNewText;

	if (sNewText.substr(0,4) == "The ")
		sText = sNewText.substring(4, iLen) + ", The";
	if (sNewText.substr(0,2) == "A ")
		sText = sNewText.substring(2, iLen) + ", A";

	return sText;
}
function SwapApost(pText)
{
	var iLen, iChar
	var sChar, sPrevChar, sText, sTextValue

	sTextValue = pText.value;
	iLen = sTextValue.length - 1;
	sChar = pText.value.charAt(0);
	sText = sChar.toUpperCase();

	for (iChar = 1; iChar <= iLen; iChar++)
	{
		sChar = sTextValue.charAt(iChar);
		if (sChar == "'" || sChar == "\"")
			sText = sText + "`";
		else
			sText = sText + sChar;
		sPrevChar = sChar;
	}

	pText.value = sText;

}
function CheckLen(oItem, iMax)
{
	if (oItem.value.length > iMax)
	{
		alert ("You've entered more that the allowed " + iMax + " characters.");
		oItem.value = oItem.value.slice(0,iMax);
		oItem.focus();
	}
}


