﻿// JScript File

    function CheckCount(txtBox) {
    	var strTextBoxCount = 320 - AllTrim(txtBox.value).length
	    if(strTextBoxCount<= -1) {
	        alert('Legal Need/Problem can not be more than 320 Characters.');	   
	    txtBox.value = txtBox.value.substring(0,320);
        strTextBoxCount = 0;
        document.getElementById("lblCharsRemain").innerHTML =  strTextBoxCount;
	    return false;
	}          
	document.getElementById("lblCharsRemain").innerHTML =  strTextBoxCount;
    }
    
    function LeftTrim(String,TrimChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 27, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // character to be trimmed.
 //
 // This function trims spaces (default) or the specified
 // character from the left of a string or form field.
 // **********************************************************
 String += ""         // Force argument to string.
 TrimChar += ""       // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 if(String.length == 0)
  return(String)
 var Count = 0
 for(Count = 0;Count < String.length;Count++)
 {
  if(!(String.charAt(Count) == TrimChar))
   return(String.substring(Count,String.length))
 }
 return("")
}

function RightTrim(String,TrimChar)
{
 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 27, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // character to be trimmed.
 //
 // This function trims spaces (default) or the specified
 // character from the right of a string or form field.
 // **********************************************************
 String += ""        // Force argument to string.
 TrimChar += ""      // Force argument to string.
 if((TrimChar == "") || (!(TrimChar.length == 1)))
  TrimChar = " "
 if(String.length == 0)
  return(String)
 var Count = 0
 for(Count = String.length -1;Count >= 0;Count--)
 {
  if(!(String.charAt(Count) == TrimChar))
   return(String.substring(0,Count + 1))
 }
 return("")
}

    function AllTrim(String,TrimChar) {

 // **********************************************************
 // Placed in the public domain by Affordable Production Tools
 // April 27, 1998
 // Web site: http://www.aptools.com
 //
 // December 2, 1998 -- Modified to allow specification of
 // character to be trimmed.
 //
 // This function trims spaces (default) or the specified
 // character from the left and the right of a string or form field.
 //
 // Note that this functions uses two other library functions,
 // TrimLeft() and TrimRight().
 // **********************************************************

 String += ""        // Force argument to string.

 TrimChar += ""      // Force argument to string.

 if((TrimChar == "") || (!(TrimChar.length == 1)))

  TrimChar = " "

 return(RightTrim(LeftTrim(String,TrimChar),TrimChar))

}
