function show_telephone_form()
{
	new Effect.SlideDown('add_phone_form', { duration: 1.0 });
}

function hide_telephone_form()
{
	new Effect.Puff('add_phone_form', { duration: 1.0 });
}

function do_add_phone(url)
{
	var telephone_type = $F('telephone_type');
	var telephone_country = $F('telephone_country');
	var telephone_number = $F('telephone_number');

	if (0 == telephone_type.toString().length)
		return;
	if (0 == telephone_country.toString().length)
		return;
	if (0 == telephone_number.toString().length)
		return;

	new Ajax.Request(url, {
		parameters: { telephone_type: telephone_type, telephone_country: telephone_country, telephone_number: telephone_number },
		asynchronous: true, 
		evalScripts: false, 
		onComplete: function(transport) {
			handle_add_telephone_response(transport)
		}
	});

	return false;
}

function handle_add_telephone_response(transport)
{
	var json = transport.responseJSON;

	var newOption = '<option value="' + json.telephone_id + '">' + json.telephone_text + '</option>';
	$('telephoneList').insert(newOption);

	$('telephone_type').selectedIndex  = 0;
	$('telephone_country').selectedIndex  = 0;
	$('telephone_number').value = '';

	hide_telephone_form();
}
