<PUBLIC:COMPONENT id="bhvMaxlength" urn="maf:Maxlength">
     <PUBLIC:PROPERTY name="maxLength" />
     <PUBLIC:ATTACH event="onkeypress" handler="doKeypress" />
     <PUBLIC:ATTACH event="onbeforepaste" handler="doBeforePaste" />
     <PUBLIC:ATTACH event="onpaste" handler="doPaste" />
	 <public:attach event="onfocus" handler="setCurrent" />
	 <public:attach event="onblur" handler="lostFocus" />

<SCRIPT language="JScript">
var FOCUS_BGCOLOR = '#CCFFFF';
var FOCUS_BDSTYLE = 'ridge';


// Keep user from entering more than maxLength characters
function doKeypress(){
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}
// Cancel default behavior
function doBeforePaste(){
     if(maxLength)
          event.returnValue = false;
}
// Cancel default behavior and create a new paste routine
function doPaste(){
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = element.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}


function setCurrent(){
	if(!window.event.srcElement.isContentEditable) return;	// do nothing if readonly
	runtimeStyle.backgroundColor = FOCUS_BGCOLOR;
	runtimeStyle.borderStyle = FOCUS_BDSTYLE;
}
function lostFocus(){
	if(!window.event.srcElement.isContentEditable) return;	// do nothing if readonly
	runtimeStyle.backgroundColor = 'white';
	runtimeStyle.borderStyle = 'inset';
}
</SCRIPT>

</PUBLIC:COMPONENT>