/**
 * @author schiesser
 */
Ext.ns('efiport.login.view');

efiport.login.view.register = function(widget){
    var that = {};
    
    that.widget = widget;
    
    that.emailField = new Ext.form.TextField({
        xtype: 'textfield',
        name: 'email',
        labelSeparator: '',
        emptyText: 'Ihre E-Mail-Adresse',
        allowBlank: false,
        vtype: 'email',
        blankText: 'Bitte eine E-Mail-Adresse angeben'
    });
	
	var commit = function(){
        var form = that.panel.getForm();
        if (form.isValid()) {
            that.widget.cregister.register(that.panel.getForm().getValues());
        }
    };
    
    that.panel = new Ext.FormPanel({
        hideLabels: false,
        labelAlign: 'top',
        header: false,
        border: false,
        width: 500,
        keys: {
            key: Ext.EventObject.ENTER,
            fn: commit
        },
        
        defaults: {
            anchor: '90%'
        },
        
        items: [{
            border: false,
            html: widget.newUserText
        }, {
            xtype: 'radiogroup',
            labelSeparator: '',
            allowBlank: false,
            blankText: 'Bitte geben Sie ihre Anrede an.',
            items: [{
                boxLabel: 'Herr',
                name: 'gender',
                inputValue: 'male'
            }, {
                boxLabel: 'Frau',
                name: 'gender',
                inputValue: 'female'
            }],
            width: '30%'
        }, {
            layout: 'column',
            anchor: '100%',
            border: false,
            items: [{
                columnWidth: 0.3,
                layout: 'form',
                border: false,
                hideLabels: true,
                items: {
                    xtype: 'textfield',
                    name: 'firstName',
                    emptyText: 'Ihr Vorname',
                    blankText: 'Bitte geben Sie Ihren Vornamen an',
                    allowBlank: false,
                    anchor: '80%'
                }
            }, {
                columnWidth: 0.7,
                layout: 'form',
                border: false,
                hideLabels: true,
                items: {
                    xtype: 'textfield',
                    name: 'lastName',
                    emptyText: 'Ihr Nachname',
                    blankText: 'Bitte geben Sie Ihren Nachnamen an',
                    allowBlank: false,
                    anchor: '86%'
                }
            }]
        }, that.emailField, {
            id: 'password',
            xtype: 'textfield',
            inputType: 'password',
            fieldLabel: 'Passwort',
            blankText: 'Bitte ein Passwort angeben',
            allowBlank: false
        }, {
            xtype: 'textfield',
            fieldLabel: 'Passwort (Wiederholung)',
            inputType: 'password',
            blankText: 'Bitte wiederholen Sie ihr Passwort',
            allowBlank: false,
            vtype: 'password',
            initialPassField: 'password'
        }]
    
    });
    
	that.panel.addButton('Zurück', function() {
		Extreme.util.ViewHelper.previousView(widget.element);
	});
    that.panel.addButton('Weiter', commit);
    
    return that;
};


