/* This function creates a hidden an IFRAME the first time it is executed
   and on subsequent calls it just returns the previously created object
   You can use it like this:
    var IFrameDoc = createHiddenIFrame();
    IFrameDoc.location.replace(URL);
   You can also apply this function to a different window object
   to create the hidden IFRAME there.
 */
function createHiddenIFrame() {
//If function is renamed, need to change references to itself below
      if (!document.createElement)
      {// todo :: implement some kind of redirection if browser doesn't support creating of dom object
            return true;
      }
      var IFrameObj = createHiddenIFrame.IFrameObj;
      var IFrameDoc;
      if (!IFrameObj && document.createElement)
      {// create the IFrame and assign a reference to the object to our global variable IFrameObj.
            // this will only happen the first time this function is called
            try
            {
                  var tempIFrame=document.createElement('iframe');
                  tempIFrame.setAttribute('id','RSIFrame');
                  tempIFrame.style.border='0px';
                  tempIFrame.style.width='0px';
                  tempIFrame.style.height='0px';
                  IFrameObj = 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 = document.frames['RSIFrame'];
                  }
            } 
            catch(exception)
            {// This is for IE5 PC, which doesn't allow dynamic creation/manipulation of iframe object.
                  // Instead, we'll fake it up by creating our own objects.
                  iframeHTML='\<iframe id="RSIFrame" style="';
                  iframeHTML+='border:0px;';
                  iframeHTML+='width:0px;';
                  iframeHTML+='height:0px;';
                  iframeHTML+='"><\/iframe>';
                  document.body.innerHTML+=iframeHTML;
                  IFrameObj = new Object();
                  IFrameObj.document = new Object();
                  IFrameObj.document.location = new Object();
                  IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
                  IFrameObj.document.location.replace = function(location) {this.iframe.src = location;}
            }
            createHiddenIFrame.IFrameObj = IFrameObj;
      }             
  
      if (IFrameObj.contentDocument)
      {      // For NS6
            IFrameDoc = IFrameObj.contentDocument;
      }
      else if (IFrameObj.contentWindow)
      {      // For IE5.5 and IE6
            IFrameDoc = IFrameObj.contentWindow.document;
      }
      else if (IFrameObj.document)
      {      // For IE5
             IFrameDoc = IFrameObj.document;
      }
      else
      {
            return;
      }
  
      return IFrameDoc;
}