jQuery.fn.ContadorCaracteres = function () 
{
	$(this).keypress(function (event) 
	{
		var maximoCaracteres = $(this).next().next().val();
		var caracteres = $(this).val().length;
		var totalCaracteres = maximoCaracteres - caracteres;
		$(this).next().text(totalCaracteres + ' ' + MSG_GERENCIADOR017);
		if(totalCaracteres < 1)
		{
			var texto = $(this).val();
			$(this).val(texto.substr(0,maximoCaracteres)).focus();
			if(event.which != 8 && event.which != 0)
			{
				return false;
			}
		}
	});	
	$(this).blur(function ()
	{
		var maximoCaracteres = $(this).next().next().val();
		var caracteres = $(this).val().length;
		var totalCaracteres = maximoCaracteres - caracteres;
		
		if(totalCaracteres < 1)
		{
			var texto = $(this).val();
			$(this).next().text('0 '+ MSG_GERENCIADOR017);
			$(this).val(texto.substr(0,maximoCaracteres)).focus();
		}
	});
}
