DaReZa = {};

Ext.onReady(function()
{

    //-----< initialize QuickTips >---------------------------------------------
    Ext.QuickTips.init();

    //-----< initialize StateManager >------------------------------------------
    // Ext.state.Manager.setProvider(new Ext.state.SessionProvider({state: Ext.appState}));

    //-----< create the DaReZa MainPanel >--------------------------------------
    var mainPanel = new DaReZaMainPanel();
    // var mainPanel = new Ext.Panel({region:'center'});

    //-----< localize MessageBox buttons >--------------------------------------
    Ext.MessageBox.buttonText.ok = "OK";
    Ext.MessageBox.buttonText.cancel = "Abbruch";
    Ext.MessageBox.buttonText.yes = "Ja";
    Ext.MessageBox.buttonText.no = "Nein";

    //-----< combine MainPanel and header in the viewport >---------------------
    DaReZa.switchToStart = function(path){ mainPanel.switchToStart(path); };
    DaReZa.switchToStdtab = function(){ mainPanel.switchToStdtab(); };
    DaReZa.switchToTabgen = function(){ mainPanel.switchToTabgen(); };
    DaReZa.switchToIHK = function(path){ mainPanel.switchToIHK(path); };
    DaReZa.switchToBayern = function(path){ mainPanel.switchToBayern(path); };
    DaReZa.switchToLinks = function(path){ mainPanel.switchToLinks(path); };
    DaReZa.switchToHilfe = function(path){ mainPanel.switchToHilfe(path); };
    DaReZa.switchToSuchen = function(){ mainPanel.switchToSuchen(); };
    DaReZa.reloadOverview = function(url){ mainPanel.reloadOverview(url); };
    DaReZa.reloadGemdat = function(url){ mainPanel.reloadGemdat(url); };
    DaReZa.reloadKrsdat = function(url){ mainPanel.reloadKrsdat(url); };
    DaReZa.gotoRegnr = function(regnr){ try{ mainPanel.gotoRegnr(regnr); } catch(e){alert(e);} };
    DaReZa.postFirmendaten = function(url,formname) { mainPanel.postFirmendaten(url,formname); };
    DaReZa.postStruktab = function(url,formname) { try{ mainPanel.postStruktab(url,formname); } catch(e){alert(e);} };
    DaReZa.setTabgenGemdat = function() { mainPanel.setTabgenGemdat(); };
    DaReZa.setTabgenKrsdat = function() { mainPanel.setTabgenKrsdat(); };
    DaReZa.changeStdtabRegionen = function() { mainPanel.changeStdtabRegionen(); }
    DaReZa.popup = function(url) { var win = window.open(url, "PopUp", "width=500,height=600,status=no,scrollbars=no,resizable=yes"); win.focus(); }
    DaReZa.performSearch = function(query) { mainPanel.performSearch(query); }

    //-----< combine MainPanel and header in the viewport >---------------------
    var viewport = new Ext.Viewport({
        layout : 'border',
        items : [
            new Ext.BoxComponent({
                region : 'north',
                el : 'header',
                height : 60
            }),
            mainPanel
         ]
    });

    //-----< set initial state >------------------------------------------------
    mainPanel.switchToIHK('/00/38');

    //-----< perform layout >---------------------------------------------------
    viewport.doLayout();

    //-----< remove loading indicator >-----------------------------------------
    /*
    setTimeout(function(){
        Ext.get('loading').remove();
        Ext.get('loading-mask').fadeOut({remove:true});
    }, 250);
    */

});
