Ext.onReady(function(){

var showRecoverPW2 = function(){
		var _w = new Ext.Window({
   		 	id: 'winRecoverPW2',
            title: messages_recoverpassword,
            closable: true,
            width: 400,
            height: 200,
            modal: true,
            layout: 'fit',
            items : new Ext.form.FormPanel({
				url: 'SubscribeHelper_recoverpassword.do',
				labelWidth: 75,
				defaults: {width: 270, allowBlank: false},
				defaultType: 'textfield',
				frame: true,
				id: 'formRecoverPW2',
				html: "<p style='padding-top: 10px;'>"+messages_recoverpassword_info+"</p>",
				items: [
					{
						fieldLabel: 'Email',
						name: 'usernamerecover',
						id: 'usernamerecover',
						allowBlank: false						
					}
				],
				listeners: 
					     {
					     	actioncomplete: function(form, action){  
					     		if (action.type == "submit") {
						     		Ext.getCmp('winRecoverPW2').close();     
						     		Ext.Msg.show({
									   title: Globals.APPNAME,
									   msg: action.result.data,
									   buttons: Ext.Msg.OK,
									   icon: Ext.MessageBox.INFO
									});
					     		}  			   
					        },
							actionfailed: function(form, action){
								var btn = Ext.getCmp('btnRecPwd2');
								btn.enable();
								btn.setText('Recupera');
					            HANDLER_ACTION_FAILED(action.result.data);
					        }
					     }
			}),
			bbar:
			[
			    {
			    	text: buttons_continue,
			    	id: 'btnRecPwd2',
			    	cls:"x-btn-text-icon",
			    	icon: 'img/accept.png',
			    	handler: function(){
			    		var btn = Ext.getCmp('btnRecPwd2');
			    		var _frm = Ext.getCmp('formRecoverPW2').getForm();

						if (_frm.isValid())	{
							btn.disable();
							btn. setText('Loading...');	
							_frm.submit();
						}
			    	}
			    },
			    {
			    	text: buttons_cancel,
			    	cls:"x-btn-text-icon",
			    	icon: 'img/cancel.png',
				    handler: function(){
				    	Ext.getCmp('winRecoverPW2').close();
				    }
			    }
			]
            });
            _w.show();
}


if (Ext.get('pwdforgt') != null){
	Ext.get('pwdforgt').on('click', showRecoverPW2);
}

if (Ext.get('btn_recoverpw') != null){
	Ext.get('btn_recoverpw').on('click', showRecoverPW2);
}


});
