// Search string that came to the location; e.g. URL/something.html?Name=Value&Name=Value ...
var locSearch = location.search;

//------------------------------------------------------------------------------
function getSearch( ) {
// Get the search string
//------------------------------------------------------------------------------

  return locSearch;

}

//------------------------------------------------------------------------------
function getValueFromSearch( strName ) {
// Return the value from the strName=Value pair
// If the name passed isn't found, "undefined" is returned
//------------------------------------------------------------------------------

  // get the location search string, remove the "?" in the front
  var strSearch = getSearch();
  var cleanString = 'undefined';
  if ( strSearch.length > 1 ) {
    // get the location search string, remove the "?" in the front
    subSearch = strSearch.substring( 1, strSearch.length );
    // get an array of the name/value pairs
    arrPairs = subSearch.split( "&" );
    var strValue = 'undefined';
    for ( i = 0; i < arrPairs.length; i++ ) {
      arrParam = arrPairs[i].split( "=" );
      if ( strName == arrParam[0] ) {
        strValue = arrParam[1];
        break;
      }
    }

    if ( strValue != 'undefined' ) {
      var l = strValue.length;
      if ( l > 0 ) {
        cleanString = strValue;
        // Change all "+" characters in the string to " "
        var p = strValue.indexOf( "+", 0 );
        while ( p >= 0 ) {
          cleanString = cleanString.substring( 0, p ) + " " + cleanString.substring( ++p, l);
          p = cleanString.indexOf( "+", 0 );
        }
      } // if ( l > 0 )
    } // if ( strValue != 'undefined' )
  } // if ( strSearch.length > 1 )

  return unescape( cleanString );

} // getValueFromSearch( strName )