--- autosave.js	2008-07-20 19:42:11.000000000 -0400
+++ /home/darren/src/drupal/users/darren/d6/autosave/autosave.js	2008-09-19 16:18:22.000000000 -0400
@@ -14,12 +14,23 @@ Drupal.saveForm = function() {
       editorIsDirty=true;
       tinyMCE.triggerSave();
     }
-    
-  //for (var i = 0; i < form_ids.length; i++) {
+    // adding FCKEditor support
+    if (typeof(FCKeditor) != 'undefined' && fckLaunchedTextareaId.length) {
+      for ( var i = 0; i < fckLaunchedTextareaId.length; i++) {
+        var text = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] ).GetXHTML();
+        document.getElementById( fckLaunchedTextareaId[i] ).value = text;
+      }
+    }
+
     form_id = Drupal.settings['form_id'].replace(/_/g, '-');
-    //else form_id = Drupal.settings['form_id'][i].replace(/_/g, '-');
     serialized = $('#' + form_id).formHash();
-    //serialized['q'] =  Drupal.settings['q'][0];
+    // removing the tokens we specified in the configuration of the module
+    var tokens = Drupal.settings['autosave_form_elements_ignore'].split('|');
+    for (var x = 0; x < tokens.length; x++) {
+      var token = tokens[x];
+      delete serialized[token];
+    }
+
     serialized['q'] =  Drupal.settings['q'];
     $.ajax({
       url: Drupal.settings['autosave_url'],
@@ -33,7 +44,7 @@ Drupal.saveForm = function() {
         setTimeout("$('#autosave-status').fadeOut('slow')", 3000);
       }
     });
-  //}
+
     if (typeof tinyMCE == 'object') {
       tinyMCE.selectedInstance.selection.moveToBookmark(editorBookmark);
     }
@@ -51,7 +62,7 @@ Drupal.configureAutosave = function() {
     $(legend).html('<span style="color: green; font-weight: bold">Autosave enabled</span>');
     $(elem_id).prepend(legend);
     $(elem_id).attr('autosave', 'true');
-    
+
     $(elem_id).click(function() {
       id = $('form', this).attr('id');
       if ($(this).attr('autosave') == 'true') {
@@ -87,7 +98,6 @@ Drupal.checkArrowsStatus = function(leng
 
 Drupal.leftArrowCallback = function(length) {
   position -= 1;
-  //$('#autosave-status #status').html('This form (' + autosaved_forms[position]['form_id'] + ') was autosaved on ' + autosaved_forms[position]['saved_date']);
   $('#autosave-status #status').html('This form was autosaved on ' + autosaved_forms[position]['saved_date']);
   $('#autosave-status').fadeIn();
   $('#autosave-status #view a').html('View');
@@ -96,7 +106,6 @@ Drupal.leftArrowCallback = function(leng
 
 Drupal.rightArrowCallback = function(length) {
   position += 1;
-  //$('#autosave-status #status').html('This form (' + autosaved_forms[position]['form_id'] + ') was autosaved on ' + autosaved_forms[position]['saved_date']);
   $('#autosave-status #status').html('This form was autosaved on ' + autosaved_forms[position]['saved_date']);
   $('#autosave-status').fadeIn();
   $('#autosave-status #view a').html('View');
@@ -116,14 +125,13 @@ if (Drupal.jsEnabled) {
       <span id="keep"><a href="#" title="Keep Saved Form - Revert to Saved">Keep</a></span></span></div>');
       autosaved_forms = Drupal.settings['autosaved_form'];
       if (autosaved_forms) {
-        // $('#autosave-status #keep a').html(''); 
         $('#autosave-status #keep').css('display', 'none').css('visibility', 'hidden');
-	      // Check if there are more than one autosaved form in the page.
+        // Check if there are more than one autosaved form in the page.
         if (autosaved_forms.length > 1) {
           // More than one autosaved form in the page, add navigation arrows.
           $('#autosave-status').append('<div id="left-arrow" class="arrow disabled"></div>');
           $('#autosave-status').append('<div id="right-arrow" class="arrow enabled"></div>');
-          
+
           Drupal.checkArrowsStatus(autosaved_forms.length, position);
         }
         $('#autosave-status #view a').click(function() {
@@ -131,18 +139,32 @@ if (Drupal.jsEnabled) {
           if ($(this).html() == 'View') {
             $('#' + autosaved_form_id).formHash(autosaved_forms[position]['serialized']);
             $('#' + autosaved_form_id).focus();
+            // for FCKEditor
+            if (typeof(FCKeditor) != 'undefined' && fckLaunchedTextareaId.length) {
+              for ( var i = 0; i < fckLaunchedTextareaId.length; i++) {
+                var text = document.getElementById( fckLaunchedTextareaId[i] ).value;
+                if (text) {
+                  FCKeditorAPI.GetInstance( fckLaunchedJsId[i] ).InsertHtml(text);
+                }
+              }
+            }
             $(this).html('Reset');
             $('#autosave-status #keep').css('display', 'inline').css('visibility', 'visible');
-            $('#autosave-status #keep a').html('Keep'); 
+            $('#autosave-status #keep a').html('Keep');
           }
           else if ($(this).html() == 'Reset') {
             form = document.getElementById(autosaved_form_id);
             form.reset();
-            if (typeof tinyMCE == 'object') $('#' + autosaved_form_id).formHash($('#' + autosaved_form_id).formHash());  
-            //$('#autosave-status #keep a').html('');
+            if (typeof tinyMCE == 'object') $('#' + autosaved_form_id).formHash($('#' + autosaved_form_id).formHash());
+            // for FCKEditor
+            if (typeof(FCKeditor) != 'undefined' && fckLaunchedTextareaId.length) {
+              for ( var i = 0; i < fckLaunchedTextareaId.length; i++) {
+                FCKeditorAPI.GetInstance( fckLaunchedJsId[i] ).InsertHtml('');
+              }
+            }
             $('#autosave-status #keep').css('display', 'none').css('visibility', 'hidden');
             $(this).html('View');
-          }    
+          }
           return false;
         });
         $('#autosave-status #ignore a').click(function() {
@@ -166,7 +188,6 @@ if (Drupal.jsEnabled) {
           Drupal.attachAutosave();
           return false;
         });
-        //$('#autosave-status #status').html('This form (' + autosaved_forms[0]['form_id'] + ') was autosaved on ' + autosaved_forms[0]['saved_date']);
         $('#autosave-status #status').html('This form was autosaved on ' + autosaved_forms[0]['saved_date']);
         $('#autosave-status').slideDown();
       }
@@ -176,4 +197,4 @@ if (Drupal.jsEnabled) {
       }
     }
   });
-} 
+}
