jQuery(document).ready(function($){

	$("#msg").keyup(function(){
			var msg = $(this).val();
            var mlength = count_chars(msg);

            if(mlength > 160)
            {
                var j  = mlength > 160 ? parseInt(Math.ceil(mlength/153)) : 1;

                result = mlength.toString() + " / " + (153*j).toString() + " &nbsp;( " + j.toString() + " messages )";
            } 
            else
            {
                var result = mlength.toString() + " / 160" + " &nbsp;( 1 message )";
            }

            $("#counter").html(result);
	})
})

