var CRegistrationPage = CFormHandler.extend({
	initialize: function()
	{
		this.parent({
			assets: {
				FormSpinner: 'resources/images/form_spinner.gif'
			},
			
			keymap: {
				'FormElements:enter': this.register.bind(this)
			}
		});
		
		$('Firstname').focus();
	},
	
	register: function()
	{
		if (this.GetLock('Registration'))
			return false;
			
		this.SetLock('Registration');
		this.Blur();
		this.ShowSpinner( 'PostSpinner', 'FormElements', 'FormSpinner', {});
		
		new Phpr_Request({
			formId: 'RegisterFormElement',
			handler:'ev{Registration_OnRegister}',
			remote: 1,
			update: 'multi',
			errorBlockId: 'RegistrationError',
			onFailure: this.displayFormError.bind(this),
			onComplete: function() {
				this.HideSpinner('PostSpinner');
				this.RemoveLock('Registration')
			}.bind(this),
			onSuccess: function() {
			}.bind(this)
		});
		
		return false;
	}
});

var RegistrationPage = null;

window.addEvent('domready', function() {
	RegistrationPage = new CRegistrationPage();
});