Ext.onReady(function(){
	Ext.QuickTips.init();
	var registerForm = new Ext.FormPanel({
		url: 'https://monetaexpress.ru/save.php?do=client/login&standalone=1',
        frame:false,
		border: false,
		standardSubmit: true,
        width: 150,
        defaults: {width: 130, allowBlank:false, hideLabel: true},
        defaultType: 'textfield',
		monitorValid: true,
		//waitMsgTarget: true,
		bodyStyle : "background-color: transparent",
		buttonAlign: 'left',
        items: [		
			{
                emptyText: 'Мобильный телефон',
                name: 'login',
				maskRe: /[0-9]/,
				regex: /^[0-9]{10}$/,
				regexText: 'Номер телефона должен быть в формате 1234567890'
            },
			{
                emptyText: 'Пароль',
                name: 'password',
                inputType: 'password'
            },
			new Ext.Button({
				text: '&nbsp;&nbsp;&nbsp;Войти&nbsp;&nbsp;&nbsp;',
				width: 80,
				formBind: true,			
				handler: function(){
					registerForm.getForm().getEl().dom.action = 'https://monetaexpress.ru/save.php?do=client/login&standalone=1';
					registerForm.getForm().submit();
				}
			}),
			{
				xtype: 'box',
				id: 'form-login-attention',
				hidden: true,
				autoEl: {
					'class': 'form-attention',
					html: 'неверное имя пользователя или пароль'
				}
			}			
        ],
		listeners: { 
			actioncomplete: function(){
				window.location.href="https://monetaexpress.ru/creditcard";
			},
			actionfailed: function(){
				Ext.getCmp('form-login-attention').show();
			}
		}
	});
	
	var recoveryForm = new Ext.FormPanel({
        url:'/save.php?do=client/login/recovery',
        frame:false,
		border: false,
        defaults: {width: 180, allowBlank:false},
        defaultType: 'textfield',
		monitorValid: true,
		//waitMsgTarget: true,
		bodyStyle : "padding: 10px; ",
		buttonAlign: 'center',
		cls: 'bluepanel',
		labelWidth: 100,
        items: [		
			{
                fieldLabel: 'login',
                name: 'login',
				maskRe: /[0-9]/,
				regex: /^[0-9]{10}$/,
				regexText: 'Номер телефона должен быть в формате 1234567890'
            },
			{
                fieldLabel: 'E-mail',
				vtype:'email',
                name: 'email'
            },			
			{
				xtype: 'box',
				autoWidth: true,
				id: 'form-recovery-attention',
				hidden: true,
				autoEl: {
					'class': 'form-attention',
					html: 'неверное сочетание имени пользователя и почтового адреса'
				}
			}		
        ],
		buttons: [
			{
				text: '&nbsp;&nbsp;&nbsp;Выслать новый пароль&nbsp;&nbsp;&nbsp;',
				width: 80,
				formBind: true,			
				handler: function(){
					recoveryForm.getForm().submit({waitMsg:'Проверка авторизации..'});
				}
			}
		],
		listeners: { 
			actioncomplete: function(){
				window.location.href="/recovery/send";
			},
			actionfailed: function(){
				Ext.getCmp('form-recovery-attention').show();
			}
		}
	});	
	
	var c = Ext.get('div-form-login');
	if(c != null)
		registerForm.render(c);

	var c = Ext.get('div-recovery-form');
	if(c != null)
		recoveryForm.render(c);		
	
});
