 //if you want to create the frame or layer dynamically, do not
 //specify a name, do something like this, new exchanger();

 function exchanger(idParam)
 {
   //hold the dynamically created iframe or layer
   this.lyr = null;

   //to remember if the iframe or layer is created dynamically.
   this.isDynamic = false;
   this.fakeid=0;

   if (idParam==null || idParam=="")
   {
     this.isDynamic = true;
     this.lyr=document.createElement("IFRAME");
     this.lyr.width=0;
     this.lyr.height=0;
     this.lyr.marginWidth=0;
     this.lyr.marginHeight=0;
     this.lyr.frameBorder=0;
     this.lyr.style.visibility="hidden";
     this.lyr.style.position="absolute";
     this.lyr.src="/nps/Empty.html";
     this.name="tongIFrame"+window.frames.length;
     //this will make IE work.
     this.lyr.setAttribute("id",this.name);
     //this will make netscape work.
     this.lyr.setAttribute("name",this.name);
     document.body.appendChild(this.lyr);

     this.lyr.src="/nps/Empty.html";
   }
   else
   {
     this.name=idParam;
     this.lyr = window.document.getElementById(idParam);
   }
 }

 exchanger.prototype.sendData=function(url)
 {
    //add an id to the url
    this.fakeid += 1;
    var newurl = "";
    if (url.indexOf("?")>=0)
    {
       newurl = url + "&fakeId=" + this.fakeid;
    }
    else
    {
       newurl = url + "?fakeId=" + this.fakeid;
    }


   var gecko = (window.navigator.userAgent.indexOf("Gecko") != -1);
   var firefox10 = gecko && (window.navigator.userAgent.indexOf("Firefox/1.0") != -1);
   if ((newurl.length<1024 && IE) || (gecko && !firefox10) )
   {
      // Use this method for small IE requests or Firefox browsers later than 1.0.
      // This method has a size limit:  ~2048 for IE6.0, and ~48K for Firefox (abt 1500 users).
      // The other method does not work on Firefox 1.5.  Appears to be a Firefox bug.  dks
      
      // In IE, if the exchanger is called from a Popup object and the user is using HTTP over SSL
      //     then the document.writeln used in the "else" causes an "Unsecure content" message
      //     To get around this we use lyr.src to send the URL instead
      // We can't do this all of the time in IE because GET urls can only be so long
      //     Above we are setting that limit at 1025.  I'm not sure if this is correct, but
      //     it is a conservitive estimate (it may be 4096).
      // We will still get the ugly message in IE for URLs over this length

      //change the window url using "get"
      this.lyr.src=newurl;
   }
   else
   {
      //
      //change the window url using "post"
      //

       //add unique info to prevent caching
       var date = new Date();
       newurl += "&unique=" + date.getTime();

       var tmp = url.split("?");
       var parms = tmp[1].split("&");
       var html = '<html>\n<head></head>\n<body>\n<form name="ExchangeRequest" method=post action="'+tmp[0]+'">\n';
       for (i=0; i<parms.length; i++)
       {
          var parm = parms[i].split("=");
          html += '<input type=hidden name="'+parm[0]+'" value="'+urlDecode(parm[1])+'">\n';
       }
       html += "</form></body></html>";
       //alert("html = "+html);

       this.lyr.contentWindow.document.writeln(html);
       this.lyr.contentWindow.document.forms[0].submit();
    }
 }

 exchanger.prototype.retrieveData=function(varName)
 {
   var w = eval("window.frames['" + this.name + "']");
   if(w)
   {
     w.hasRead = true;
   }

   return eval("window.frames['" + this.name + "']." + varName);
 }


 exchanger.prototype.hasRead=function()
 {
   var w = eval("window.frames['" + this.name + "']");
   if(w)
   {
     return w.hasRead;
   }
   else
   {
     return false;
   }
 }


