function limitText(limitField, limitCount, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } else {
        limitCount.value = limitNum - limitField.value.length;
    }
}

function expandingBox( box_id ) {
    var oldValue = $(box_id).value;
    setInterval(function(){
        var newValue = $(box_id).value;
        if (newValue != oldValue) {//Value has changed
            //Set the "rows" attribute to the number of lines + 1
            $(box_id).writeAttribute('rows', newValue.split("\n").length+1);
            oldValue = newValue;
        }
    }, 500);//Check every 0.5s
}


function clearText(field){

    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}