/**
 * 
 * All content on this website (including text, images, source
 * code and any other original works), unless otherwise noted,
 * is licensed under a Creative Commons License.
 * 
 * http://creativecommons.org/licenses/by-nc-sa/2.5/
 * 
 * Copyright (C) 2004-2010 Open-Xchange, Inc.
 * Mail: info@open-xchange.com 
 * 
 * @author Matthias Biggeleben <matthias.biggeleben@open-xchange.com>
 * 
 */

ox.gui.morph = function () {

    // widget pool
    ox.widgets = {};
    
    // set topmost layout manager
    ox.desktop.setLayout(new ox.gui.ZeroLayout());
    
    // create dummy space
    var park = $("<div/>", { id: "dompark" }).css({
        position: "absolute",
        display: "none"
    }).appendTo(document.body);
    
    // move sidepanel's children
    var sidenode = $("#sidesplit");
    sidenode.css({ margin: "0px" }).
        children().appendTo(park);
    
    // init
    ox.gui.initController();
    ox.gui.initToppanel();
    ox.gui.initSidepanel(sidenode);
    ox.gui.initFolderTree();
    ox.gui.initConfigTree();
    // toolbar
    if (true) {
        // init toolbar controller
        var $p = ox.gui.initToolBar(); // returns some shared private functions/vars.
        ox.gui.initToolBarCore(); // init the core toolbar, depends on initToolBar 
        ox.gui.initToolBarPortal($p);
        ox.gui.initToolBarMail($p);
        ox.gui.initToolBarCalendar($p);
        ox.gui.initToolBarContacts($p);
        ox.gui.initToolBarTasks($p);
        ox.gui.initToolBarInfoStore($p);
        ox.gui.initToolBarConfig($p);
        ox.gui.initToolBarMessaging($p);
        ox.gui.initToolBarPermissions($p);
        
        $p.postInit();
    }
    
    // i18n
    register("LanguageChanged", function () {
        // event forward
        ox.desktop.triggerGlobalEvent("LanguageChanged");
    });
};
