var ns6=document.getElementById&&!document.all

function count(e,placeholder){
	var theform=eval(placeholder)
	var textlength=theform.value.length
	var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
	if (window.event||e.target&&e.target==eval(placeholder)){
		theform.value=theform.value.substring(0,textlength)
		placeholderobj.innerHTML=textlength
	}
}


function displaycount(theform){
	var count_text='<font color=#FF0000><span id="'+theform.toString()+'">0</span></font>'
	if (document.all||ns6)
		document.write(count_text)
	if (document.all){
		eval(theform).onkeyup=function(){ count(event,theform)}
	}
	else if (ns6){
		document.body.addEventListener('keyup', function(event) { count(event,theform) }, true); 
	}
}

function showCharsLeft(fieldname, charsleft) {
	charfield = document.getElementById(charsleft);
	messagefield = document.getElementById(fieldname);
	charfield.firstChild.nodeValue = messagefield.value.length;
}
