/*
 * Copyright 1999-2002 by Vignette, Inc.,
 * All rights reserved.
 * 
 * This software is the confidential and proprietary information
 * of Vignette, Inc. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Vignette.
 * 
 */

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

function exchanger(name){
  //hold the dynamically created iframe or layer
  this.lyr = null;
  //to remember if the iframe or layer is created dynamically.
  this.isDynamic = false;
  this.name=name||"";
  this.fakeid=0;
  if(name==null||name==""){
    this.isDynamic=true;
    this.create();
  } else {
    this.name=name;
    if(bw.ns4) this.lyr=window.document.layers[this.name];
  }
}

//this function should not be called directly
exchanger.prototype.create=function(){
  if(bw.ns4){
    this.lyr=new Layer(0);
    this.visibility="hide";
  } else if(bw.ie||bw.ns6){
    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="";
    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);
  }
}

exchanger.prototype.sendData=function(url){
  if(!url) return;
  this.fakeid+=1;
  var newurl="";
  if(url.indexOf("?")>=0){
   if("&"==url.charAt(url.length-1)){
   	newurl=url+"fakeId"+this.fakeid+"=aValue";
   } else {
   	newurl=url+"&fakeId"+this.fakeid+"=aValue";
   }
  } else newurl=url+"?fakeId"+this.fakeid+"=aValue";
    
  if(this.isDynamic||bw.ns4) this.lyr.src=newurl;
  else {
    if(bw.ie||bw.ns6||bw.op5||bw.op6){
      window.frames[this.name].document.location.replace(newurl);
    }
  }
}

exchanger.prototype.retrieveData=function(varName){
  if(at.ns4) return eval("this.lyr." + varName);
  else if (at.ie || at.ns5 || at.op) return eval("window.frames['"+this.name+"']."+varName);
}



