<!--

// maxlength.js by http://www.quirksmode.org/
// 1. onload="setMaxLength()" in BODY tag
// 2. Add maxlength="1500" to textarea tag: <textarea name="message" rows="7" cols="50" maxlength="1500"></textarea>
// 3. Send button does have to be labled "Submit" in order to be disabled when too much text
// 4. CSS style of type "toomuch": .toomuch {color: red} 
// 5. Add <script language="JavaScript" src="../../js/maxlength.js" type="text/JavaScript"> to HTML
// =======================================================================================
// With this script you can restrict the input in textareas.

function setMaxLength()
{
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('maxlength'))
		{
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength()
{
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		{
		this.relatedElement.className = 'toomuch';
		document.forms[0].Submit.disabled=true;
		}
	else
		{
		this.relatedElement.className = '';
		document.forms[0].Submit.disabled=false;
		}
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

//-->
