var processing = false;

function init() {
	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'under';

	//start lostpassword
var lostPasswordForm = new Ext.FormPanel({
		renderTo: Ext.DomQuery.selectNode('#lostpassword_form'),
		labelWidth: 125,
		labelAlign: 'right',
		frame: false,
		border: false,
		monitorValid: true,
		defaults: {
			width: 250
		},
		defaultType: 'textfield',
		items: [{
				fieldLabel: 'Email',
				name: 'email',
				allowBlank: false,
				vtype: 'email'
			},{
				name: 'method',
				value: 'resetPassword',
				xtype: 'hidden'
			}
		],
		buttonAlign: 'left',
		buttons: [{
			text: 'Submit',
			formBind: true,
			handler: function() {
				if (processing == false) {
					processing = true;
					lostPasswordForm.form.submit({
						url: '/ajax.php',
						method: 'post',
						success: function(form, action) {
							processing = false;
							var message = 'An email has been sent to the address that you specified with your temporary password.';
							Ext.MessageBox.alert('Success!', message);
						},
						failure: function(form, action) {
							processing = false;
							var message = !Ext.isEmpty(action.result.statusMessage) ? action.result.statusMessage : 'An unknown error was encountered.';
							Ext.MessageBox.alert('Error', message);
						}
					});
				}	
			}
		}],
		keys: {
			key: Ext.EventObject.ENTER,
			fn: function() { Ext.DomQuery.selectNode('#lostpassword button:first').click(); }
		}
	});
	Ext.DomQuery.selectNode('#lostpassword_form input:first').focus();	
}