// Written by Tan Ling Wee on December 2, 2001.
// E-mail: fuushikaden@yahoo.com

// Written by James P. Carlin on June 8, 2008.
// E-mail: isijpc@hotmail.com

/*
 * Returns a string in which all non-alphanumeric characters have been replaced with a
 * percent (%) sign followed by two hex digits.
 * 
 *  Special      %                                 
 * Character   ASCII   Description
 * ---------   -----   ----------------------------
 *     !        %21    Exclamation mark           
 *     "        %22    Quotation mark
 *     #        %23    Number
 *     $        %24    Dollar
 *     %        %25    Percent  
 *     &        %26    Ampersand
 *     '        %27    Apostrophe
 *     (        %28    Left parenthesis
 *     )        %29    right parenthesis
 *     +        %2B    Plus (not encoded by escape)
 *     :        %3A    Colon
 *     ;        %3B    Semicolon 
 *     <        %3C    Less than
 *     =        %3D    Equals
 *     >        %3E    Greater than
 *     ?        %3F    Question mark
 *     [        %5B    Left square bracket
 *     \        %5C    Reverse solidus (backslash)
 *     ]        %5D    Right square bracket
 *     ^        %5E    Caret
 *     `        %60    Grave accent
 *     {        %7B    Left curly brace
 *     |        %7C    Vertical bar
 *     }        %7D    Right curly brace
 *     ~        %7E    Tilde			
 */

function encodeURL (dataString)
  {
   // Use the escape() function to encode special characters.
   var urlString = escape(dataString);

   // Use regular expressions to replace plus symbol (+) with %2B where 2B is the ASCII
   // encoding for each plus symbol in the argument (data string). 
   return urlString = urlString.replace(/[+]/g, "%2B");
  }

