function rollOn(obj) {
	obj.className = "button_on";
}

function rollOut(obj) {
	obj.className = "button_off";
}


//<!----------------     BEGIN TCS_CharacterCounter.jsp       --------------->



var countingField = null;
var firstTime = true;


function textAreaCounter(field){
    if (countingField!=null && countingField==field){
        var totalLength=0;
        for (i=0;i<countingFields.length;i++){
            totalLength+=countingFields[i].value.length;
        }
        if (totalLength>MAXCHAR){
            if ( textAreaCtrAlert!=null ) {
            	alert(textAreaCtrAlert);
            } else {
            	alert("Maximum message length reached." + 
        	" " + MAXCHAR +"Your message has been truncated at" +
        	" " + len + " " + "characters.");
            }
            field.value = field.value.substring(0,field.value.length+MAXCHAR-totalLength);
            counterField.value = 0;
        }
        else{
            counterField.value = MAXCHAR-totalLength;
        }
        field.blur();
        field.focus();
    }
}

function startTextAreaCounter(field){
    if (!firstTime && countingField==field) countingField=field;
    else {
        countingField = field;
        firstTime = false;
    }
}

function stopTextAreaCounter(field){
    countingField = null;
}

function onKeyEventCounter(field){

    var len = 0;
    
    for (i=0; i<countingFields.length; i++){
        len += countingFields[i].value.length;
    }

    if ( len > MAXCHAR ){
        if ( onKeyEventCtrAlert!=null ) {
        	alert(onKeyEventCtrAlert);
        } else {
        	alert("Maximum message length reached." + 
        	" " + MAXCHAR +"Your message has been truncated at" +
        	" " + len + " " + "characters.");
        	
        }
        field.value=field.value.substring(0,field.value.length+MAXCHAR-len);
        counterField.value = 0;
        field.focus();
    }
    else{
        counterField.value = (MAXCHAR - len);
    }
}


//<!----------------     END   TCS_CharacterCounter.jsp       --------------->