//******************************************************************************
// FUNCTION:	TextEntryLimit
//******************************************************************************
// DESC:		Determines if entry limit has been reached
// PARAMS:		objEvent -	element
//******************************************************************************
function TextEntryLimit(objEvent)
{

	// Get the event source
	if(objEvent)
	{
		var intMaxLength = objEvent.getAttribute("MaxLength");
		
		if(objEvent.value.length == (intMaxLength*1))
		{
			return false;
		}
	}
}


//******************************************************************************
// FUNCTION:	TextCounter
//******************************************************************************
// DESC:	Decrements the counter element
// PARAMS:	obj -	    element
//			id  -	    the id of the element to decrement the innerHTML
//					    (i.e. <span id=count />
//          intLength - Length of text allowed
//******************************************************************************
function TextCounter(objEvent, charCountId, wordCountId, intLength)
{ 
    var intMaxLength = intLength;
    
	if(objEvent)
	{
		var intTextLength = objEvent.value.length;
		var intCount = (intMaxLength - intTextLength);

		if (intTextLength > (intMaxLength*1))
		{
			objEvent.value = objEvent.value.substring(0,(intMaxLength*1));
		}									
		
		if (charCountId && wordCountId)
		{
			// If count is a number			
			if(!isNaN(intCount))
			{
				var objCounterText = document.getElementById(charCountId);
				var objWordCounterText = document.getElementById(wordCountId);
				// If there is an element
				if(objCounterText)
				{
					if (intTextLength-1 < intMaxLength)	{
						objCounterText.innerHTML = intCount;
					    objWordCounterText.innerHTML = intCount/5;
					}
				}
			}
		}
	}
}