var registration_dialogue;
var registration;

function init_registration()
{
	var aRegistrationCss = { Instruction : 'REG_instruction', SelectedInstruction: 'REG_selected_instruction',
							 ErrorMessage : 'REG_error_message' };
	
	var aRegistrationElements = new Array
	(
		new RegistrationElement
		(
			'txtRegisterEmail',
			'lblRegisterEmail',
			new ClientCondition (
				function(o) {
					var email_regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					return email_regex.test(o.value);
				}, 'Please enter a valid e-mail address.', '1'
			),
			new ServerCondition('2', 'That e-mail address is already in use.'),
			aRegistrationCss
		),
		
		new RegistrationElement
		(
			'txtRegisterPassword',
			'lblRegisterPassword',
			new ClientCondition(function(o) { return o.value.length >= 3; }, 'Must be at least 3 characters', '3'),
			null,
			aRegistrationCss
		),
		
		new RegistrationElement
		(
			'chkRegisterTerms',
			'lblRegisterTerms',
			new ClientCondition
			(
				function(o) { return o.checked; },
				'You must agree to the <a href="jsRequired.php" onclick="createPopup(\'terms.html\', 640, 400, 300, 300); return false;"> Terms of Service</a>',
				'4'
			),
			null,
			aRegistrationCss
		)
	);
	
	// registration and registration_dialogue defined globally
	registration = new Registration('formRegister', aRegistrationElements);
	
	var dialogue_css = { header: 'dialogue_header', ok_button: 'form_button', close_link: 'close_link', header_text: 'header_text' };	
	registration_dialogue = new Dialogue('divRegistration', 'Sign Up', dialogue_css, '#E62764', 475, false, null, null);
	
	if (Util.QueryString('error_code') != '')
		registration_dialogue.Show();
}