--- orig/autosave.js	2008-10-08 18:44:12.000000000 +0200
+++ ../modules/autosave/autosave.js	2008-10-08 18:42:36.000000000 +0200
@@ -5,22 +5,33 @@
 var autosaved_forms;
 
 Drupal.attachAutosave = function() {
-  setTimeout('Drupal.saveForm()', Drupal.settings['period'] * 1000);
+  setTimeout(function () { Drupal.saveForm() }, Drupal.settings['period'] * 1000);
 }
 
 Drupal.saveForm = function() {
     if (typeof tinyMCE == 'object') {
-      editorBookmark = tinyMCE.selectedInstance.selection.getBookmark();
+      var editorBookmark = tinyMCE.selectedInstance.selection.getBookmark();
       editorIsDirty=true;
       tinyMCE.triggerSave();
     }
-    
+
+    if (typeof FCKeditorAPI == 'object') {
+      for( var i = 0 ; i < fckLaunchedJsId.length ; i++ ) {
+        var fck = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] )
+        fck.UpdateLinkedField();
+      }
+    }
+
   //for (var i = 0; i < form_ids.length; i++) {
-    form_id = Drupal.settings['form_id'].replace(/_/g, '-');
+    var form_id = Drupal.settings['form_id'].replace(/_/g, '-');
     //else form_id = Drupal.settings['form_id'][i].replace(/_/g, '-');
-    serialized = $('#' + form_id).formHash();
+    var serialized = $('#' + form_id).formHash();
     //serialized['q'] =  Drupal.settings['q'][0];
     serialized['q'] =  Drupal.settings['q'];
+    
+    // Do not serialize the buttons
+    delete serialized.op;
+    
     $.ajax({
       url: Drupal.settings['autosave_url'],
       type: "POST",
@@ -30,30 +41,30 @@
         $('#autosave-status #status').html('Form autosaved.');
         $('#autosave-status #operations').css('display', 'none').css('visibility', 'hidden');
         $('#autosave-status').slideDown();
-        setTimeout("$('#autosave-status').fadeOut('slow')", 3000);
+        setTimeout(function() { $('#autosave-status').fadeOut('slow') }, 3000);
       }
     });
   //}
     if (typeof tinyMCE == 'object') {
       tinyMCE.selectedInstance.selection.moveToBookmark(editorBookmark);
     }
-    setTimeout('Drupal.saveForm()', Drupal.settings['period'] * 1000);
+    setTimeout(function() { Drupal.saveForm() }, Drupal.settings['period'] * 1000);
 }
 
 Drupal.configureAutosave = function() {
   $('form').each(function(index) {
-    id = $(this).attr('id');
-    fieldset = document.createElement('fieldset');
+    var id = $(this).attr('id');
+    var fieldset = document.createElement('fieldset');
     fieldset.id = 'autosave-' + id;
-    elem_id = '#autosave-' + id;
-    legend = document.createElement('legend');
+    var elem_id = '#autosave-' + id;
+    var legend = document.createElement('legend');
     $(this).wrap(fieldset);
     $(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');
+      var id = $('form', this).attr('id');
       if ($(this).attr('autosave') == 'true') {
         $('form', this).css('opacity', '0.2');
         $('legend', this).html('<span style="color: #FFAE00; font-weight: bold">Autosave disabled</span>');
@@ -70,7 +81,7 @@
 }
 
 Drupal.checkArrowsStatus = function(length, pos) {
-  pos += 1;
+  var pos += 1;
   if (pos == 1) {
     $('#left-arrow').removeAttr('class').attr('class', 'arrow disabled').unbind('click');
     $('#right-arrow').removeAttr('class').attr('class', 'arrow enabled').unbind('click').bind('click', function() { Drupal.rightArrowCallback(length, pos) });
@@ -131,6 +142,14 @@
           if ($(this).html() == 'View') {
             $('#' + autosaved_form_id).formHash(autosaved_forms[position]['serialized']);
             $('#' + autosaved_form_id).focus();
+            
+            if (typeof FCKeditorAPI == 'object') {
+              for( var i = 0 ; i < fckLaunchedJsId.length ; i++ ) {
+                var fck = FCKeditorAPI.GetInstance( fckLaunchedJsId[i] )
+                fck.SetHTML($('#' + fckLaunchedJsId[i]).val());
+              }
+            }
+            
             $(this).html('Reset');
             $('#autosave-status #keep').css('display', 'inline').css('visibility', 'visible');
             $('#autosave-status #keep a').html('Keep'); 
@@ -176,4 +195,4 @@
       }
     }
   });
-} 
+}
