Index: source/class/pf/Application.js
===================================================================
--- source/class/pf/Application.js	(revision 249)
+++ source/class/pf/Application.js	(revision 251)
@@ -2117,53 +2117,9 @@
         },
 
-        savePreferences : function()
-        {
-            if (this.prefs) {
-                var prefstr = qx.util.Json.stringify(this.prefs);
-                qx.bom.Cookie.set("pf_prefs", prefstr, 3650);
-            }
-        },
-        
-        loadPreferences : function()
-        {
-            var prefstr = qx.bom.Cookie.get("pf_prefs");
-            
-            if (prefstr) {
-                this.prefs = qx.util.Json.parse(prefstr);
-            }
-            
-            if (!this.prefs) {
-                this.prefs = new Object;
-            }
- 
-            if (undefined === this.prefs.rememberWindowSize) {
-                this.prefs.rememberWindowSize = false;
-            }
-
-            if (undefined === this.prefs.autoLoadWiki) {
-                this.prefs.autoLoadWiki = true;
-            }
-            
-            if (undefined === this.prefs.warnOnExit) {
-                this.prefs.warnOnExit = true;
-            }
-            
-            if (!this.prefs.units) {
-                this.prefs.units = new Object;
-            }
-            
-            if (!this.prefs.currentConfigName) {
-                this.prefs.currentConfigName = "Untitled";
-            }
-            
-            if (!this.prefs.configPtrs) {
-                this.prefs.configPtrs = new Array;
-            }
-        },
-
-        saveFavorites : function()
+        exportFavorites : function()
         {
             var sfavs = new Array;
             var len = this.favorites.length;
+            
             for (var k = 0; k < len; k++) {
                 var fav  = this.favorites[k];
@@ -2180,49 +2136,45 @@
                     sfav.s2_id = null;
                 }
-                sfav.color      = fav.color;
+                sfav.color     = fav.color;
                 sfavs.push(sfav);
             }
             
-            var favstr = qx.util.Json.stringify(sfavs);
-            qx.bom.Cookie.set("pf_favs", favstr, 3650);
-        },
-        
-        loadFavorites : function()
-        {
+            return sfavs;
+        },
+
+        importFavorites : function(sfavs)
+        {
+            if (!sfavs) {
+                return false;
+            }
+
             this.favorites = new Array;
             
-            var favstr = qx.bom.Cookie.get("pf_favs");
-            
-            if (favstr) {
-                var sfavs = qx.util.Json.parse(favstr);
-                if (!sfavs) {
-                    return;
-                }
-                
-                var len = sfavs.length;
-                for (var k = 0; k < len; k++) {
-                    var sfav = sfavs[k];
-                    var fav  = new Object;
-                    fav.entity = this.getEntityById(sfav.entity_id);
-                    // old format
-                    if (sfav.species_id) {
-                        fav.s1 = this.getSpeciesById(sfav.species_id);
-                    } else
-                    if (sfav.s1_id) {
-                        fav.s1 = this.getSpeciesById(sfav.s1_id);
-                    }
-
-                    if (sfav.s2_id) {
-                        fav.s2 = this.getSpeciesById(sfav.s2_id);
-                    }
-                    fav.color = sfav.color;
-                    
-                    if (fav.entity && fav.color) {
-                        this.favorites.push(fav);
-                    }
-                }
-            }
-        },
-        
+            var len = sfavs.length;
+            for (var k = 0; k < len; k++) {
+                var sfav = sfavs[k];
+                var fav  = new Object;
+                fav.entity = this.getEntityById(sfav.entity_id);
+                // old format
+                if (sfav.species_id) {
+                    fav.s1 = this.getSpeciesById(sfav.species_id);
+                } else
+                if (sfav.s1_id) {
+                    fav.s1 = this.getSpeciesById(sfav.s1_id);
+                }
+
+                if (sfav.s2_id) {
+                    fav.s2 = this.getSpeciesById(sfav.s2_id);
+                }
+                fav.color = sfav.color;
+
+                if (fav.entity && fav.color) {
+                    this.favorites.push(fav);
+                }
+            }
+            
+            return true;
+        },
+
         getConfig : function(name)
         {
@@ -2245,4 +2197,75 @@
         },
         
+        savePreferences : function()
+        {
+            if (this.prefs) {
+                var prefstr = qx.util.Json.stringify(this.prefs);
+                qx.bom.Cookie.set("pf_prefs", prefstr, 3650);
+            }
+        },
+        
+        loadPreferences : function()
+        {
+            var prefstr = qx.bom.Cookie.get("pf_prefs");
+            
+            if (prefstr) {
+                this.prefs = qx.util.Json.parse(prefstr);
+            }
+            
+            if (!this.prefs) {
+                this.prefs = new Object;
+            }
+ 
+            if (undefined === this.prefs.saveFavsWithConfig) {
+                this.prefs.saveFavsWithConfig = true;
+            }
+            
+            if (undefined === this.prefs.rememberWindowSize) {
+                this.prefs.rememberWindowSize = false;
+            }
+
+            if (undefined === this.prefs.autoLoadWiki) {
+                this.prefs.autoLoadWiki = true;
+            }
+            
+            if (undefined === this.prefs.warnOnExit) {
+                this.prefs.warnOnExit = true;
+            }
+            
+            if (!this.prefs.units) {
+                this.prefs.units = new Object;
+            }
+            
+            if (!this.prefs.currentConfigName) {
+                this.prefs.currentConfigName = "Untitled";
+            }
+            
+            if (!this.prefs.configPtrs) {
+                this.prefs.configPtrs = new Array;
+            }
+        },
+        
+        saveFavorites : function()
+        {
+            var sfavs = this.exportFavorites();
+            
+            var favstr = qx.util.Json.stringify(sfavs);
+            
+            qx.bom.Cookie.set("pf_favs", favstr, 3650);
+        },
+        
+        loadFavorites : function()
+        {
+            this.favorites = new Array;
+            
+            var favstr = qx.bom.Cookie.get("pf_favs");
+            
+            if (favstr) {
+                var sfavs = qx.util.Json.parse(favstr);
+                
+                this.importFavorites(sfavs);
+            }
+        },
+        
         saveConfig : function(name)
         {
@@ -2290,4 +2313,8 @@
             config.n_u = this.plasma.n_u;
             config.n_l = this.plasma.n_l;
+            
+            if (this.prefs.saveFavsWithConfig) {
+                config.favorites = this.exportFavorites();
+            }
             
             var configstr = qx.util.Json.stringify(config);
@@ -2351,4 +2378,8 @@
                 this.plasma.n_u = config.n_u;
                 this.plasma.n_l = config.n_l;
+                
+                if (this.prefs.saveFavsWithConfig && config.favorites) {
+                    this.importFavorites(config.favorites);
+                }
 
                 this.prefs.currentConfigName = name;
@@ -2529,4 +2560,7 @@
                                 this.updatePlasmaParameters();
                                 this.updateGUI();
+                                if (this.prefs.saveFavsWithConfig) {
+                                    this.rePopulateTree();
+                                }
                                 this.drawAll();
                                 this.saveLoadWindow.close();
@@ -2557,4 +2591,16 @@
             
             var fr, l, e;
+
+            fr = new qx.ui.groupbox.GroupBox("General");
+            fr.setLayout(new qx.ui.layout.VBox(10));
+            w.add(fr);
+
+            e = new qx.ui.form.CheckBox("Save favorites with configurations");
+            e.setValue(this.prefs.saveFavsWithConfig);
+            e.addListener("changeValue", function(ev) {
+                this.prefs.saveFavsWithConfig = ev.getTarget().getValue();
+                this.savePreferences();
+            }, this);
+            fr.add(e);
             
             fr = new qx.ui.groupbox.GroupBox("Default units");
