//$Revision: 1.7 $
function CheckLength(s, limit){
    if (s.value.length > limit){
        alert("Text is too long. Must be " + limit + " characters or less");
        return false;
    }
    return true;
}

function StrBreak(str, len) {
	return str.replace(new RegExp("(?!<\\s)(\\S{" + ((len) ? len : 30) + "})(?!\\s)", "g"), "$1 ");
}

function StrTruncate(str, len) {
	alert('-1- [' + str + ']');
	alert('-2- [' + str.replace(new RegExp("^(.{5}).+$"), "$1...", "ms") + ']');
	alert('-3- [' + str + ']');

	return str.replace(new RegExp("^(.{" + ((len) ? len : 30) + "}).+$"), "$1...");
}

function LimitLength(field, errorElementId, maxlimit) {
	var errorElement = document.getElementById(errorElementId);
	if (field.value.length > maxlimit) { // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	        errorElement.style.visibility = "visible";
	}

        if (field.value.length < maxlimit) {
                errorElement.style.visibility = "hidden";
        }
}


