dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.TimeTextBox");

function _textCounter(field, counter, max, sms) {
    if (sms) {
        if (field.value.length > 160) {
            counter.style.color = 'red';
        } else {
            counter.style.color = 'black';
        }
    }
    if (field.value.length > max) {
        field.value = field.value.substring(0, max);
    } else {
        counter.value = max - field.value.length;
    }
}

function textCounter(field, counter) {
    _textCounter(field, counter, 460, true);
}

function textCounterContent(field, counter) {
    _textCounter(field, counter, 6000, false);
}

function textCounterHeader(field, counter) {
    _textCounter(field, counter, 160, false);
}
