function countlimit(maxlength,e,placeholder){
if (window.event||e.target&&e.target==eval(placeholder)){
//if (lengthleft<0)
//{
	//theform.value=theform.value.substring(0,maxlength)
//}
displayCharacters(maxlength,placeholder);
}

}
function displayCharacters(maxlength,placeholder)
{
	var theform=eval(placeholder)
	
	var lengthleft=maxlength-theform.value.length
	
	var placeholdertexto=document.all? document.all["limitetexto"] : document.getElementById("limitetexto")		
	if(lengthleft>=0)
	{
		placeholdertexto.innerHTML='Quedan <span id="limitechar">'+lengthleft+'</span> caracteres'
	}
	else
	{
		
		placeholdertexto.innerHTML='<span class="limiteexcedido">Ha excedido el l&iacute;mite en <span id="limitechar">'+String(lengthleft).substr(1,String(lengthleft).length)+'</span> caracteres</span>'
	}
}

function displaylimit(thename, theid, thelimit){

var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<div id="limitetexto">Quedan <span id="limitechar">'+thelimit+'</span> caracteres</div>'
document.write(limit_text)
if(document.all)
{
	eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else
{
	document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
displayCharacters(thelimit,theform)
}
