function trim( inputStringTrim ) 
{
   fixedTrim = "";
   lastCh = " ";
   
   for (x=0; x < inputStringTrim.length; x++) 
   {
      ch = inputStringTrim.charAt(x);
      if ((ch != " ") || (lastCh != " ")) { fixedTrim += ch; }
         lastCh = ch;
   }
   
   if (fixedTrim.charAt(fixedTrim.length - 1) == " ") 
   {
      fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1); 
   }
   
   return fixedTrim
}

//check empty
function checkEmpty(FldValue, FldName)
{
   if (trim(FldValue) == "")
   {
      errMsg += "-  " + FldName + " is required.\n"
      return false
   }
   
   return true
}

// validate for numeric
function checkNum(FldValue, FldName) 
{
   var reInteger = /^\d+/
   var reSignedInteger  = /^(\+|-)?\d+$/ 
   var flagError = 0

   // check for numeric
	if (!reInteger.test(FldValue)) 
      flagError += 1
   
   // check for "-,.,etc."
   if (!reSignedInteger.test(FldValue)) 
      flagError += 1        
   
   if (flagError > 0)
   {
      errMsg += "-  " + FldName + " is an invalid number.\n"  
      return false
   }
   
   return true
}

// validate for numeric
function checkNumxcpthypen(FldValue, FldName) 
{
   var reInteger = /^\d+/
   var reSignedInteger  = /\-?\d/



   var flagError = 0

   // check for numeric
	//if (!reInteger.test(FldValue)) 
    //  flagError += 1
   
   // check for "-,.,etc."
   if (!reSignedInteger.test(FldValue)) 
      flagError += 1        
   
   if (flagError > 0)
   {
      errMsg += "-  " + FldName + " is an invalid number.\n"  
      return false
   }
   
   return true
}

// validate for numeric
function checkNumLetters(FldValue, FldName) 
{
   var reInteger = /^\d+/
   var reSignedInteger  = /\w/ 
   var flagError = 0

   // check for numeric
	if (!reInteger.test(FldValue)) 
      flagError += 1
   
   // check for "-,.,etc."
   if (!reSignedInteger.test(FldValue)) 
      flagError += 1        
   
   if (flagError > 0)
   {
      errMsg += "-  " + FldName + " is an invalid number.\n"  
      return false
   }
   
   return true
}

function checkStrLength(FldValue, FldMinLength, FldMaxLength, FldName)
{
   if (FldValue != "")
   {
      if (FldValue.length < FldMinLength || FldValue.length > FldMaxLength) 
      {
         errMsg += "-  " + FldName + " must be between " + FldMinLength + " and " + FldMaxLength + " characters.\n"  
         return false
      }
   }
   
   return true
}