Ext.ns('Ext.pv.form');
Ext.pv.form.EmailField = Ext.extend(Ext.form.TextField, {
	vtype : 'email',
	enableKeyEvents : true,
	
	listeners : {
		// Ensure email addresses are always entered in lower case.
		keyup : function(field, event) {
			// Commented out Sep 14, 2011, due to PV-681:
			//  This causes issues with the cursor position.  If a user performs an edit in the middle of the
			//  string, their cursor will be pushed to the end of the string following this event handler.
			//field.clean();
		},
		blur : function(field, event) {
			field.clean();
		},
		scope : this
	},
	
	clean : function () {
		var value = this.getValue();
		var newValue = value.toLowerCase();
		newValue = newValue.replace(/\s/,'');
		if (value!=newValue) {
			this.setValue(newValue);
		}
	}
});
Ext.reg('emailfield', Ext.pv.form.EmailField);
