/*-- Put this javascript code at the top of your .html file --*/
//   form_data = createRequestObject();
//   var page_responce=form_data["page_responce"];
/*-- ------------------------------------------------------ --*/

function createRequestObject()
{
     /*-- The Object ("Array") where our data will be stored. --*/
     form_data = new Object();
  
     /*-- The token used to separate data from multi-select inputs --*/
     separator = ',';
    
     /*-- Get the current URL so we can parse out the data. --*/
     /*-- Adding a null-string '' forces an implicit type cast --*/
     /*-- from property to string, for NS2 compatibility. --*/
     query = '' + this.location;

     /*-- Keep everything after the question mark '?'. --*/
     query = query.substring((query.indexOf('?')) + 1);

     /*-- Perhaps we got some bad data? --*/
     if (query.length < 1) { return false; }
  
     /*-- Local vars used to store and keep track of name/value pairs --*/
     /*-- as we parse them back into a usable form. --*/
     keypairs = new Object();
     numKP = 1;
    
     while (query.indexOf('&') > -1)
     {
          /*-- Split the query string at each '&', storing the left-hand side --*/
          /*-- of the split in a new keypairs[] holder, and chopping the query --*/
          /*-- so that it gets the value of the right-hand string. --*/
          keypairs[numKP] = query.substring(0,query.indexOf('&'));
          query = query.substring((query.indexOf('&')) + 1);
          numKP++;
     }

     /*-- Store what's left in the query string as the final keypairs[] data. --*/
     keypairs[numKP] = query;

  
     for (i in keypairs)
     {
          /*-- Left of '=' is name. --*/
          keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));

          /*-- Right of '=' is value --*/
          keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);

          while (keyValue.indexOf('+') > -1)
          {
               /*-- Replace each '+' in data string with a space. --*/
               keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
          }
          
          /*-- Unescape non-alphanumerics --*/    
          keyValue = unescape(keyValue);
      
          if (form_data[keyName])
          {
               /*-- Object already exists, it is probably a multi-select input, --*/
               /*-- and we need to generate a separator-delimited string --*/
               /*-- by appending to what we already have stored. --*/
               form_data[keyName] = form_data[keyName] + separator + keyValue;
          }
          else
          {
               /*-- Normal case: name gets value. --*/
               form_data[keyName] = keyValue;
          }
     }

     return form_data;
}
