// JavaScript Document

$(document).ready(function()
{
//	$('#edit-field-reg-password-0-value').attr('type', 'password');
	$('#edit-submit').click(function() {
			return checkPasswords();
		});
	
	$('#edit-field-reg-age-value').bind('change', function() { updateFields(); });
	
	$('#edit-field-reg-country-value-can').bind('click', function() { updateFields(); });
	$('#edit-field-reg-country-value-us').bind('click', function() { updateFields(); });
	$('#edit-field-reg-country-value-other').bind('click', function() { updateFields(); });
	
	updateFields();
	
	
	$('#confirm-password-wrapper label').html('Confirm Password: <span style="color: red">*</span>');
	$('#edit-field-reg-email-parent-0-value-wrapper label').html('Parent or Guardian\'s Email Address:');// <span style="color: red">*</span>');
});

function checkPasswords() {
	
	if ($('#edit-field-reg-password-0-value').val() != $('#confirm').val()) {
		alert('Sorry, but your passwords do not match...');
		return false;
	}
}

function updateFields() {
	
	//
	// Make sure something's checked from the country...
	//
	if (($('#edit-field-reg-country-value-can').is(':checked') ||
		$('#edit-field-reg-country-value-us').is(':checked')) &&
		!$('#edit-field-reg-country-value-other').is(':checked')) {
		
		$('#contest-begin').show();
		$('#edit-field-reg-email-0-value-wrapper').show();
		$('#edit-submit').show();
	}
	else {
		$('#contest-begin').hide();
		$('#edit-field-reg-email-0-value-wrapper').hide();
		$('#edit-submit').hide();
		
		if ($('#edit-field-reg-country-value-other').is(':checked'))
			$('#edit-submit').show(); // Still show the submit button for other countries
	}
	
	if ($('#edit-field-reg-country-value-can').is(':checked') && $('#edit-field-reg-age-value').val() == '12-')
		$('#edit-field-reg-email-parent-0-value-wrapper').show();
	else
		$('#edit-field-reg-email-parent-0-value-wrapper').hide();
}
