<!-- trims white space off the tail of a string -->
function RTrim(str)  
{
   return( (ar=/(^[\s\S]*\S+)\s*$/.exec(str)) ? ar[1] : "" ); 
}

<!-- trims white space off the head of a string -->
function LTrim(str)    
{
   return( (ar=/^\s*([\s\S]*$)/.exec(str)) ? ar[1] : "" ); 
}

<!-- trims white space off both ends of a string -->
function Trim(str)    
{
   return( (ar=/^\s*([\s\S]*\S+)\s*$/.exec(str)) ? ar[1] : "" );
}

<!-- test for Numeric complete number string -->
function IsNumeric(strString)
{
   <!-- Declaration of Variables -->
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   <!-- test strString consists of valid characters listed above -->
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
 
     if (strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
   }

   return blnResult;
}

<!-- Replace any character with another character -->
function Replace(Entry, InChar, OutChar) 
{
   <!-- Declaration of Variables -->
   var Temp = "" + Entry; 
   var PositionOfChar;

   <!-- Loop through all characters in string and replace
   while (Temp.indexOf(InChar)>-1) 
   {
	PostionOfChar = Temp.indexOf(InChar);
	Temp = "" + (Temp.substring(0, PostionOfChar) + OutChar + 
	Temp.substring((PostionOfChar + InChar.length), Temp.length));
   }

   return Temp;

}

<!-- display a new browser window -->
function DisplayWindow(url,h,w) 
{
  <!-- Declaration of Variables -->
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;

  <!-- Dispaly new browser window -->
  popupWindow =
    eval("window.open('"+url+"', '', 'width="+w+",height="+h+
    ",top="+wint+",left="+winl+
    ",menubar=no,toolbar=no,location=center,scrollbars=no"+
    ",resizable=no,status=no,location=no')")
}

<!-- display a new browser window -->
function DisplayWindowScroll(url,h,w) 
{
  <!-- Declaration of Variables -->
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;

  <!-- Dispaly new browser window -->
  popupWindow =
    eval("window.open('"+url+"', '', 'width="+w+",height="+h+
    ",top="+wint+",left="+winl+
    ",menubar=no,toolbar=no,location=center,scrollbars=Yes"+
    ",resizable=no,status=no,location=no')")
}

<!-- Checks if the string is a valid date -->
function isDate(sDate) 
{
  <!-- Declaration of Local Variables -->
  var aiDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  var iDay;
  var iMonth;
  var iYear;

  
  <!-- Check for slashes -->
  if (sDate.substring(1, 2) == '/') 
  {
    <!-- Get all numbers up to char. (32/12/2000) = 32) --> 
    iDay = parseInt(sDate.substring(0, 1), 10);
 
    if (sDate.substring(3, 4) == '/') 
    {
      iMonth = parseInt(sDate.substring(2, 3), 10);
      iYear = parseInt(sDate.substring(4, 8), 10);
    }
    else 
    {
      iMonth = parseInt(sDate.substring(2, 4), 10);
      iYear = parseInt(sDate.substring(5, 9), 10);
    }
  }
  else 
  {
    iDay = parseInt(sDate.substring(0, 2), 10);
    if (sDate.substring(4, 5) == '/') 
    {
      iMonth = parseInt(sDate.substring(3, 4), 10);
      iYear = parseInt(sDate.substring(5, 9), 10);
    }
    else 
    {
      iMonth = parseInt(sDate.substring(3, 5), 10);
      iYear = parseInt(sDate.substring(6, 10), 10);
    }
  }
  
  <!-- Check for day, month, year less than 1 --> 
  if (iDay < 1 || iMonth < 1 || iYear < 0)
    return 0;
  
  <!-- Check for month greater than 12 -->  
  if (iMonth > 12)
    return 0;

  <!-- Check for two digit year or 4 digit year -->
  iYear += iYear < 100 ? iYear > 10 ? 1900 : 2000 : 0;

  <!-- Create array of days for date -->  
  aiDays[1] += (iYear % 4 ? 0 : iYear % 100 ? 1 : iYear % 400 ?
    iYear == 200 ? 1 : 0 : 1);

  <!-- Check if day in date is correct -->
  return (iDay <= aiDays[iMonth - 1]);
}