Index: plugin.js
===================================================================
--- plugin.js	(revision 62)
+++ plugin.js	(working copy)
@@ -4,18 +4,18 @@
  * This is a rather sophisticated plugin to show a dialog to insert
  * <fn> footnotes or edit existing ones. It produces and understands
  * the <fn>angle bracket</fn> variant and uses the fakeObjects API to
- * show a nice icon to the user, while producing proper <fn> tags when 
- * the text is saved or View Source is pressed. 
+ * show a nice icon to the user, while producing proper <fn> tags when
+ * the text is saved or View Source is pressed.
  *
- * If a text contains footnotes of the [fn]square bracket[/fn] variant, 
+ * If a text contains footnotes of the [fn]square bracket[/fn] variant,
  * they will be visible in the text and this plugin will not react to them.
  *
  * This plugin uses Drupal.t() to translate strings and will not as such
  * work outside of Drupal. (But removing those functions would be the only
- * change needed.) While being part of a Wysiwyg compatible module, it could 
+ * change needed.) While being part of a Wysiwyg compatible module, it could
  * also be used together with the CKEditor module.
- * 
- * Drupal Wysiwyg requirement: The first argument to CKEDITOR.plugins.add() 
+ *
+ * Drupal Wysiwyg requirement: The first argument to CKEDITOR.plugins.add()
  * must be equal to the key used in $plugins[] in hook_wysiwyg_plugin().
  */
 CKEDITOR.plugins.add( 'footnotes',
@@ -67,20 +67,21 @@
                 {
                   id : 'footnote',
                   type : 'text',
-                  label : Drupal.t('Footnote text :'),
+                  label : Drupal.t('Footnote text :')
                 },
                 {
                   id : 'value',
                   type : 'text',
                   label : Drupal.t('Value :'),
                   labelLayout : 'horizontal',
-                  style : 'float:left;width:100px;',
+                  style : 'float:left;width:100px;'
                 }
               ]
             }
           ],
         onShow : function()
         {
+
          this.editObj = false;
          this.fakeObj = false;
          this.editMode = false;
@@ -89,7 +90,7 @@
          var ranges = selection.getRanges();
          var element = selection.getSelectedElement();
          var seltype = selection.getType();
-         
+
          if ( seltype == CKEDITOR.SELECTION_ELEMENT && element.getAttribute( '_cke_real_element_type' ) && element.getAttribute( '_cke_real_element_type' ) == 'fn' )
          {
           this.fakeObj = element;
@@ -99,29 +100,67 @@
          }
          else if ( seltype == CKEDITOR.SELECTION_TEXT )
          {
-           this.setValueOf( 'info','footnote', selection.getNative() );
+
+           var selectedText;
+           if (CKEDITOR.env.ie) {
+             selection.unlock(true);
+             selectedText = selection.getNative().createRange().text;
+			 selection.lock();
+           }
+           else {
+             selectedText = selection.getNative();
+           }
+
+           this.setValueOf( 'info','footnote', selectedText );
          }
+
          this.getContentElement( 'info', 'footnote' ).focus();
         },
           onOk : function()
           {
+
+
             var editor = this.getParentEditor();
             var content = this.getValueOf( 'info', 'footnote' );
             var value = this.getValueOf( 'info', 'value' );
+
+
             if ( content.length > 0 || value.length > 0 ) {
-              var realElement = CKEDITOR.dom.element.createFromHtml('<fn></fn>');
+
+              var userAgent = navigator.userAgent.toLowerCase();
+              // Test if the browser is IE and check the version number is lower than 9
+              if (/msie/.test(userAgent) &&
+                  parseFloat((userAgent.match(/.*(?:rv|ie)[\/: ](.+?)([ \);]|$)/) || [])[1]) < 9) {
+
+                  var ie_version = parseFloat((userAgent.match(/.*(?:rv|ie)[\/: ](.+?)([ \);]|$)/) || [])[1]);
+                if (ie_version >= 8) {
+                  editor.insertHtml('<fn value="' + value + '">' + content + '</fn>');
+                  return;
+                }
+                // Navigate to error page
+                var realElement = CKEDITOR.document.createElement( 'fn' );
+				//var realElement = new CKEDITOR.dom.element('fn');
+              }
+              else {
+                var realElement = CKEDITOR.dom.element.createFromHtml('<fn></fn>');
+              }
+
+				//console.log(realElement.getName());
+
               if ( content.length > 0 )
                 realElement.setText(content);
               if ( value.length > 0 )
                 realElement.setAttribute('value',value);
+
               var fakeElement = editor.createFakeElement( realElement , 'cke_footnote', 'fn', false );
               editor.insertElement(fakeElement);
+
             }
           }
         };
       });
       editor.addCommand('footnotes', new CKEDITOR.dialogCommand('footnotesDialog'));
-      // Drupal Wysiwyg requirement: The first argument to editor.ui.addButton() 
+      // Drupal Wysiwyg requirement: The first argument to editor.ui.addButton()
       // must be equal to the key used in $plugins[<pluginName>]['buttons'][<key>]
       // in hook_wysiwyg_plugin().
       editor.ui.addButton('footnotes',
@@ -140,7 +179,7 @@
           {
             footnotes :
               {
-                label : Drupal.t('Edit footnote'),  
+                label : Drupal.t('Edit footnote'),
                 command : 'footnotes',
                 icon : this.path + 'images/footnotes.png',
                 group : 'footnotes'
@@ -172,7 +211,7 @@
                 'fn' : function( element )
                   {
                       var fakeElement = editor.createFakeParserElement(element, 'cke_footnote', 'fn', false );
-                      return fakeElement;  
+                      return fakeElement;
                   }
               }
           },
