function toggle_parent_info(make_visible)
{
	if (make_visible)
	{
		$('player_email_row').hide();
		
		$('parent_email').setValue($('player_email').getValue());
		$('player_email').setValue('');

		$('parent_info').show();
	}
	else
	{
		$('parent_info').hide();

		if (!$('submit_button').disabled)
		{
			// don't swap if the button is disabled since that means
			// the user is just now clicking on Player
			$('player_email').setValue($('parent_email').getValue());
			$('parent_email').setValue('');
		}

		$('player_email_row').show();
	}

	$('submit_button').disabled = false;
}

function zip_code_lookup(zip_code, parent_or_player)
{
	if (zip_code == '') return;
	if (isNaN(zip_code)) return;
	
	var ajax = new Ajax.Request('/zipCode.php', {
		asynchronous: false,
		method: 'get',
		eval: false,
		parameters: {
			action: 'search',
			zipcode: zip_code
		}
	});
	
	var xml = ajax.transport.responseXML;
	var is_new_zip = xml.getElementsByTagName('NewZip')[0].firstChild.data == 'true';

	if (is_new_zip)
	{
		$(parent_or_player + '_city').activate();
	}
	else
	{
		var city = xml.getElementsByTagName('City')[0].firstChild.data;
		var state = xml.getElementsByTagName('State')[0].firstChild.data;
		$(parent_or_player + '_city').value = city;
		setSelectedItem($(parent_or_player + '_state'), state);
		$(parent_or_player + '_phone_1').activate(); 
	}
}

function copy_player_info_to_parent()
{
	$('parent_street_1').setValue($('player_street_1').getValue());
	$('parent_street_2').setValue($('player_street_2').getValue());
	$('parent_city').setValue($('player_city').getValue());
	$('parent_zip_code').setValue($('player_zip_code').getValue());
	setSelectedItem($('parent_state'), $('player_state').getValue());
	$('parent_phone_1').setValue($('player_phone_1').getValue());
	$('parent_phone_2').setValue($('player_phone_2').getValue());
	$('parent_phone_3').setValue($('player_phone_3').getValue());
}