/*
 Copyright(C) 1999-2002 Active Web Services, LLC.
 All Rights Reserved.
*/

// remove left spaces
function strTrimLeft( str, spaceChars )
{
  var re = new RegExp( "^\\s+", "" );
  if( spaceChars )
    re = new RegExp( "^[" + spaceChars + "]+", "" );

  return str.replace( re, "" );
}

// remove right spaces
function strTrimRight( str, spaceChars )
{
  var re = new RegExp( "\\s+$", "" );
  if( spaceChars )
    re = new RegExp( "[" + spaceChars + "]+$", "" );

  return str.replace( re, "" );
}

// remove leading spaces
function strTrim( str, spaceChars )
{
  return strTrimRight( strTrimLeft(str, spaceChars), spaceChars );
}

// format string
function strFormat()
{
  var re = /%s/;
  if( arguments.length < 1 )
    return "";

  var result = arguments[0];
  for( var i = 1; i < arguments.length; i++ )
    result = result.replace( re, arguments[i] );

  return result;
}

// url decode
function urlDecode( url )
{
  var re = /\+/g;
  return unescape( url.replace( re, " " ) );
}

