$(document).ready(function(){
	$('textarea[maxlength]').keyup(function(){
		var max = parseInt($(this).attr('maxlength'));
		if($(this).val().length > max){
			$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
		}
		if ($(this).next().attr("tagName")!=null && $(this).next().attr("tagName").toUpperCase() == "SPAN")
		{
			$(this).next().html('<font color=red>' + (max - $(this).val().length) + '</font>');
		}
	});
	$('textarea[maxlength]').blur(function(){
		var max = parseInt($(this).attr('maxlength'));
		if($(this).val().length > max){
			$(this).val($(this).val().substr(0, $(this).attr('maxlength')));
		}
		if ($(this).next().attr("tagName")!=null && $(this).next().attr("tagName").toUpperCase() == "SPAN")
		{
			$(this).next().html('<font color=red>' + (max - $(this).val().length) + '</font>');
		}
	});
});
function checksize(ta)
{
	var max = parseInt($(ta).attr('maxlength'));
	if($(ta).val().length > max){
		$(ta).val($(ta).val().substr(0, $(ta).attr('maxlength')));
	}
	if ($(ta).next().attr("tagName")!=null && $(ta).next().attr("tagName").toUpperCase() == "SPAN")
	{
		$(ta).next().html('<font color=red>' + (max - $(ta).val().length) + '</font>');
	}
}