docs: function refresh(editor) {
  
      var $main = editor.$main,
        options = editor.options;
  
      // Remove the old iframe
      if (editor.$frame) 
        editor.$frame.remove();
  
      // Create a new iframe
      var $frame = editor.$frame = $('<iframe frameborder="0" src="javascript:true;">')
        .hide()
        .appendTo($main);
  
      // Load the iframe document content
      var contentWindow = $frame[0].contentWindow,
        doc = editor.doc = contentWindow.document,
        $doc = $(doc);
  
      doc.open();
      doc.write(
        options.docType +
        '<html>' +
        ((options.docCSSFile === '') ? '' : '<head><link rel="stylesheet" type="text/css" href="' + options.docCSSFile + '" /></head>') +
        '<body style="' + options.bodyStyle + '"></body></html>'
      );
      doc.close();
  
      // Work around for bug in IE which causes the editor to lose
      // focus when clicking below the end of the document.
      if (ie)
        $doc.click(function() {focus(editor);});
  
      // Load the content
      updateFrame(editor);
  
      // Bind the ie specific iframe event handlers
      if (ie) {
  
        // Save the current user selection. This code is needed since IE will
        // reset the selection just after the beforedeactivate event and just
        // before the beforeactivate event.
        $doc.bind("beforedeactivate beforeactivate selectionchange keypress", function(e) {
          
          // Flag the editor as inactive
          if (e.type == "beforedeactivate")
            editor.inactive = true;
          
          // Get rid of the bogus selection and flag the editor as active
          else if (e.type == "beforeactivate") {
            if (!editor.inactive && editor.range && editor.range.length > 1)
              editor.range.shift();
            delete editor.inactive;
          }
  
          // Save the selection when the editor is active
          else if (!editor.inactive) {
            if (!editor.range) 
              editor.range = [];
            editor.range.unshift(getRange(editor));
  
            // We only need the last 2 selections
            while (editor.range.length > 2)
              editor.range.pop();
          }
  
        });
  
        // Restore the text range when the iframe gains focus
        $frame.focus(function() {
          restoreRange(editor);
        });
  
      }
  
      // Update the textarea when the iframe loses focus
      ($.browser.mozilla ? $doc : $(contentWindow)).blur(function() {
        updateTextArea(editor, true);
      });
  
      // Enable the toolbar buttons as the user types or clicks
      $doc.click(hidePopups)
        .bind("keyup mouseup", function() {
          refreshButtons(editor);
        });
  
      // Show the textarea for iPhone/iTouch/iPad or
      // the iframe when design mode is supported.
      if (iOS) editor.$area.show();
      else $frame.show();
  
      // Wait for the layout to finish - shortcut for $(document).ready()
      $(function() {
  
        var $toolbar = editor.$toolbar,
            $group = $toolbar.children("div:last"),
            wid = $main.width();
  
        // Resize the toolbar
        var hgt = $group.offset().top + $group.outerHeight() - $toolbar.offset().top + 1;
        $toolbar.height(hgt);
  
        // Resize the iframe
        hgt = (/%/.test("" + options.height) ? $main.height() : parseInt(options.height)) - hgt;
        $frame.width(wid).height(hgt);
  
        // Resize the textarea. IE6 textareas have a 1px top
        // & bottom margin that cannot be removed using css.
        editor.$area.width(wid).height(ie6 ? hgt - 2 : hgt);
  
        // Switch the iframe into design mode if enabled
        disable(editor, editor.disabled);
  
        // Enable or disable the toolbar buttons
        refreshButtons(editor);
  
      });
  
    }