<!-- 
 Developer : PO-Arvind
 Date      : 30/12/2009
 Reference : SGComments_Updated_24122009.xls
             This code has been referenced from existing file named maxlength2000.htc 
 Purpose   : For max length 500 
 Status    : To be align with POV70
 Starts here ======================================================================
-->
<public:component id="bhvMaxlength" urn="maf:Maxlength">
     <public:attach event="onkeypress" handler="doKeypress" />
     <public:attach event="onbeforepaste" handler="doBeforePaste" />
     <public:attach event="onpaste" handler="doPaste" />
     <!-- 
		Example of use:
		TEXTAREA { behavior: url(maxlength500.htc); } 
     -->
<script language="JScript">
	
	function doKeypress(){
		var maxLength = 490;
		if(maxLength && value.length > maxLength-1){
			event.returnValue = false;
			maxLength = parseInt(maxLength);
		}
	}
	
	function doBeforePaste(){
		event.returnValue = false;
	}
	
	function doPaste(){
		var maxLength = 490;
		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;
	}
</script>

</public:component>
<!-- 
End here ====================================================================
-->