Index: code/branches/menu/data/gui/layouts/MainMenu.layout
===================================================================
--- code/branches/menu/data/gui/layouts/MainMenu.layout	(revision 6024)
+++ code/branches/menu/data/gui/layouts/MainMenu.layout	(revision 6032)
@@ -1,11 +1,6 @@
 <?xml version="1.0" ?>
 <GUILayout>
-    <Window Type="TaharezLook/StaticImage" Name="orxonox/Background">
-    <Property Name="UnifiedSize" Value="{{1.0,0},{1.0,0}}"/>
-    <Property Name="Image" Value="set:MainMenuBackground image:Background"/>
-    <Property Name="FrameEnabled" Value="set:true"/>
-    <Property Name="BackgroundEnabled" Value="set:false"/>
-    <Property Name="InheritsAlpha" Value="False" />
- 
+    <Window Type="DefaultWindow" Name="orxonox/MainMenuRootWindow">
+    <Property Name="InheritsAlpha" Value="false"/>
         <Window Type="TaharezLook/Button" Name="orxonox/StandaloneButton">
             <Property Name="UnifiedPosition" Value="{{0.11,0},{0.3,0}}"/>
Index: code/branches/menu/data/gui/scripts/InitialiseGUI.lua
===================================================================
--- code/branches/menu/data/gui/scripts/InitialiseGUI.lua	(revision 6024)
+++ code/branches/menu/data/gui/scripts/InitialiseGUI.lua	(revision 6032)
@@ -19,4 +19,5 @@
 root = nil
 bShowsCursor = false
+bHidePrevious = {}
 
 -- loads the GUI with the specified filename
@@ -32,5 +33,4 @@
         if table.getn(loadedGUIs) == 1 then
             current = loadedGUIs[1]
-            showing = false
         end
         -- hide new GUI as we do not want to show it accidentially
@@ -40,6 +40,6 @@
 end
 
-function showGUI(filename, bCursorVisible, ptr)
-    gui = showGUI(filename, bCursorVisible)
+function showGUI(filename, hidePrevious, bCursorVisible, ptr)
+    gui = showGUI(filename, hidePrevious, bCursorVisible)
     gui.overlay = ptr
 end
@@ -47,15 +47,11 @@
 -- shows the specified and loads it if not loaded already
 -- be sure to set the global variable "filename" before calling this function
-function showGUI(filename, bCursorVisible)
---     bCursorVisibile=false
+function showGUI(filename, hidePrevious, bCursorVisible)
     if bCursorVisible == nil then
-        cursorVisibility= true
+        bCursorVisible = true
     end
 
     if root == nil then
-        root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow")
-        root:setProperty("Alpha", "0.0")
-        root:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
-        system:setGUISheet(root)
+        setBackground("")
     end
 
@@ -65,5 +61,9 @@
     end
 
+    debug("test")
+    debug(currentGUI.window:getName())
+    debug(root:isChild(currentGUI.window))
     if(root:isChild(currentGUI.window)) then
+        debug("removing window")
         root:removeChildWindow(currentGUI.window)
     end
@@ -75,12 +75,21 @@
         hideCursor()
     end
-    cursorVisibility[filename]=bCursorVisible
     
+    if find( activeSheets, filename ) ~= nil then
+        table.remove( activeSheets, find( activeSheets, filename ) )
+        nrOfActiveSheets = nrOfActiveSheets - 1
+    end
     nrOfActiveSheets = nrOfActiveSheets + 1
     table.insert(activeSheets, filename)
     activeSheets[nrOfActiveSheets] = filename
+    bHidePrevious[filename]=hidePrevious
+    cursorVisibility[filename] = bCursorVisible
     
+    if hidePrevious == true then
+        for i=1,nrOfActiveSheets-1 do
+            loadedGUIs[ activeSheets[i] ]:hide()
+        end
+    end
     currentGUI:show()
-    showing = true
     return currentGUI
 end
@@ -106,7 +115,17 @@
     end
     currentGUI:hide()
+    if bHidePrevious[filename] == true then
+        local i = nrOfActiveSheets-1
+        while i>0 do
+            loadedGUIs[ activeSheets[i] ]:show()
+            if bHidePrevious[filename]==true then
+                break
+            else
+                i=i-1
+            end
+        end
+    end
     root:removeChildWindow(currentGUI.window)
-    showing = false
-    i=1
+    local i=1
     while activeSheets[i] do
         if activeSheets[i+1] == nil then
@@ -129,3 +148,44 @@
     end
     cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
+    bHidePrevious[filename] = nil
 end
+
+function setBackground(filename)
+    local newroot
+    if root ~= nil then
+        root:rename("oldRootWindow")
+    end
+    if filename ~= "" then
+        newroot = winMgr:loadWindowLayout(filename .. ".layout")
+        newroot:rename("AbsoluteRootWindow")
+        system:setGUISheet(newroot)
+    else
+        newroot = winMgr:createWindow("DefaultWindow", "AbsoluteRootWindow")
+        newroot:setProperty("Alpha", "0.0")
+        newroot:setSize(CEGUI.UVector2(CEGUI.UDim(1.0,0),CEGUI.UDim(1.0,0)))
+        system:setGUISheet(newroot)
+    end
+    if root ~= nil then
+        local child
+        for i=0,root:getChildCount()-1 do
+            child = root:getChildAtIdx(i)
+            root:removeChildWindow(child)
+            newroot:addChildWindow(child)
+        end
+        winMgr:destroyWindow(root)
+    end
+    newroot:show()
+    root = newroot
+end
+
+function find(table, value)
+    local i=0
+    while table[i] ~= nil do
+        if table[i]==value then
+            return i
+        else
+            i=i+1
+        end
+    end
+    return nil
+end
Index: code/branches/menu/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/menu/src/libraries/core/GUIManager.cc	(revision 6024)
+++ code/branches/menu/src/libraries/core/GUIManager.cc	(revision 6032)
@@ -89,5 +89,5 @@
     GUIManager* GUIManager::singletonPtr_s = 0;
 
-    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, true);
+    SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
     SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
 
@@ -210,5 +210,5 @@
         For more details check out loadGUI_2.lua where the function presides.
     */
-    /*static*/ void GUIManager::showGUI(const std::string& name, bool showCursor)
+    /*static*/ void GUIManager::showGUI(const std::string& name, bool hidePrevious, bool showCursor)
     {
         std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name);
@@ -220,5 +220,6 @@
             InputManager::getInstance().enterState("guiMouseOnly");
         }
-        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ")");
+        COUT(0) << "showGUI" << endl;
+        GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ")");
     }
 
@@ -227,5 +228,5 @@
         Hack-ish. Needed for GUIOverlay.
     */
-    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor)
+    void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious, bool showCursor)
     {
         std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name);
@@ -237,5 +238,5 @@
             InputManager::getInstance().enterState("guiMouseOnly");
         }
-        this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
+        this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(hidePrevious) + ", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
     }
 
@@ -258,4 +259,15 @@
         }
     }
+    
+    void GUIManager::setToggleMode(const bool& mode)
+    {
+        this->bToggleMode_ = mode;
+        this->executeCode("setToggleMode(" + multi_cast<std::string>(mode) + ")");
+    }
+    
+    void GUIManager::setBackground(const std::string& name)
+    {
+        this->executeCode("setBackground(\"" + name + "\")");
+    }
 
     void GUIManager::keyPressed(const KeyEvent& evt)
Index: code/branches/menu/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/menu/src/libraries/core/GUIManager.h	(revision 6024)
+++ code/branches/menu/src/libraries/core/GUIManager.h	(revision 6032)
@@ -68,7 +68,9 @@
         void update(const Clock& time); 
 
-        static void showGUI(const std::string& name, bool showCursor=true);
-        void showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor=true);
+        static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true);
+        void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
         static void hideGUI(const std::string& name);
+        void setToggleMode(const bool& mode);
+        void setBackground(const std::string& name);
 
         void setCamera(Ogre::Camera* camera);
@@ -111,4 +113,5 @@
 
         static GUIManager*                   singletonPtr_s;    //!< Singleton reference to GUIManager
+        bool                                 bToggleMode_;
 
     };
Index: code/branches/menu/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/menu/src/orxonox/gamestates/GSMainMenu.cc	(revision 6024)
+++ code/branches/menu/src/orxonox/gamestates/GSMainMenu.cc	(revision 6032)
@@ -82,6 +82,8 @@
     {
         // show main menu
-        GUIManager::getInstance().showGUI("MainMenu", false);
+        GUIManager::getInstance().showGUI("MainMenu", true, false);
         GUIManager::getInstance().setCamera(this->camera_);
+        GUIManager::getInstance().setBackground("MainMenuBackground");
+//         GUIManager::getInstance().setBackground("");
         GraphicsManager::getInstance().setCamera(this->camera_);
 
@@ -113,4 +115,5 @@
 
         GUIManager::getInstance().setCamera(0);
+        GUIManager::getInstance().setBackground("");
         GUIManager::hideGUI("MainMenu");
         GraphicsManager::getInstance().setCamera(0);
