// ------------------------------------------------------------------
// editable iFrame
// ------------------------------------------------------------------
// returns the editable iFrame object from the iFrame object, given
function createEditableIFrame( iFrame )
{
  object = new Object();
  object.iFrame = iFrame;
  
  // assigning public methods
  object.getDocument = editableIFrameGetDocument;
  object.setDocument = editableIFrameSetDocument;
  object.initialize = editableIFrameInitialize;
  
  // initialization
  object.initialize();
  
  // done
  return object;
}

// performs initialization operations on the given editable frame
// object
function editableIFrameInitialize()
{
  if ( this.iFrame )
  {
    var document = this.getDocument();

    document.designMode = "On";
    
    this.setDocument( document );
  }
  else
    return false;
}

// ---------------------------------------------------------------
// these functions are designed to be used internally

// returns the document object for the iFrame of this object
// or false in case of an error
function editableIFrameGetDocument()
{
  if ( this.iFrame.contentDocument )
    return this.iFrame.contentDocument;
  else if ( this.iFrame.contentWindow && this.iFrame.contentWindow.document )
    return this.iFrame.contentWindow.document;
  /* there's something wrong with this scheme
  else if ( this.iFrame.document )
    return this.iFrame.document;*/
  else
    return false;
}

// changes the document object the iFrame of the current object
// to the one, given
// or false in case of an error
function editableIFrameSetDocument( newDocument )
{
  if ( this.iFrame.contentDocument )
  {
    for ( var i in this.iFrame.contentDocument )
    {
      try
      {
        this.iFrame.contentDocument[ i ] = newDocument[ i ];
      }
      catch (e) { };
    };
  }
  else if ( this.iFrame.contentWindow && this.iFrame.contentWindow.document )
  {
    for ( var i in this.iFrame.contentWindow.document )
    {
      try
      {
        this.iFrame.contentWindow.document[ i ] = newDocument[ i ];
      }
      catch (e) { };
    };
  }/* there's something wrong with it
  else if ( this.iFrame.document )
  {
    for ( var i in this.iFrame.document )
    {
      try
      {
        this.iFrame.document[ i ] = newDocument[ i ];
      }
      catch (e) { };
    };
  }
  else
    this.iFrame.document = newDocument;*/
}