window.addEvent('domready', function() {
    $$('.char_count').each(function(target) {
        setInterval(function() {
            var id = target.parentNode.getAttribute('for');
            var length = $(id).value.length;
            if (length < 1000) {
                target.setHTML('[' + (1000 - length) + ' chars left]');
            } else if (length == 1000) {
                target.setHTML('[1000 chars');
            } else if (length > 1000) {
                target.setHTML('[' + (length - 1000) + ' chars over]');
            }
        }, 500);
    });
});

