var IFrameObj = new Array(15); // our IFrame object

function rpcInvoke(index,URL) { 

//alert ('Invoke');

  if (!document.createElement) {return true};
  var IFrameDoc;
  if (!IFrameObj[index] && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame' + index);
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px'; 
      tempIFrame.style.height='0px';
      IFrameObj[index] = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj[index] = document.frames['RSIFrame'+index];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.

      var dv = document.createElement ('div');
	  dv = document.body.appendChild (dv);
	  dv.innerHTML = '<iframe id="RSIFrame'+ index +'" style="border:0px;width:0px;height:0px;"></iframe>'

      /* old method not working for ie 5
      iframeHTML='\&lt;iframe id="RSIFrame'+ index +'" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"&gt;&lt;\/iframe&gt;';
      dv.innerHTML=iframeHTML;
      IFrameObj[index] = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame'+index);
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
        alert('replace')
      }
	  */
      if (document.frames) {
        IFrameObj[index] = document.frames['RSIFrame'+index];
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj[index].contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('rpcInvoke(index, URL)',10);
    return false;
  }
  
  if (IFrameObj[index].contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj[index].contentDocument; 
  } else if (IFrameObj[index].contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj[index].contentWindow.document;
  } else if (IFrameObj[index].document) {
    // For IE5
    IFrameDoc = IFrameObj[index].document;
  } else {
    return true;
  }

  IFrameDoc.location.replace(URL);

  return false;
  
}

function rpcHandle(source,target)
{
	var targetObj = _findObj(target);
	targetObj.innerHTML = source.innerHTML;
}

function rpcAddOption(theSel, theText, theValue)
{
	var cbObj = _findObj(theSel);
	addOption(cbObj, theText, theValue);
}

function rpcResetOption(theSel)
{
	var cbObj = _findObj(theSel);
	cbObj.length = 0
}
