Ext.onReady(function() {
    var submitLoginForm = function() {
        
        var extForm = [
            Ext.getCmp('login_mail'),
            Ext.getCmp('login_pass')
        ];
        var origForm =  [
            Ext.get('hiddenusername'),
            Ext.get('hiddenpassword')
        ];
        origForm[0].dom.value = extForm[0].getValue();
        origForm[1].dom.value = extForm[1].getValue();
        document.forms["hiddenForm"].submit();
    };
    var loginForm = new Ext.form.FormPanel({
        url             : baseUrl + 'entry/login',
        standardSubmit  : true,
        items           : [
            {
                xtype       : 'textfield',
                id          : 'login_mail',
                name        : 'username',
                emptyText   : 'Emailadresse',
                width       : 137,
                hideLabel   : true
            }, {
                xtype           : 'textfield',
                id              : 'login_pass',
                enableKeyEvents : true,
                emptyText       : 'Passwort',
                hideLabel       : true,
                width           : 137,
                name            : 'password',
                inputType       : 'password',
                listeners       : {
                    keyPress        : function(me, e) {
                        if (e.getKey() == e.ENTER) {
                            submitLoginForm();
                        }
                    }
                }
            }
        ],
        renderTo        : 'loginForm',
        hideLabel       : true,
        bbar            : {
            items   : [
                '->',
                {
                    text    : 'Login',
                    handler : submitLoginForm
                }
            ]
        }
    });
    var origForm =  [
        Ext.get('hiddenusername'),
        Ext.get('hiddenpassword')
    ];
    var extForm = [
        Ext.getCmp('login_mail'),
        Ext.getCmp('login_pass')
    ];
    extForm[0].setValue(origForm[0].dom.value);
    extForm[1].setValue(origForm[1].dom.value);
});
