
//var g_current_general_url; // Will be initialized at the top of the body

function Ajax_LoadAddressBook(user_type_code, force_create_new)
{
	var address_book_id;
	if(!force_create_new)
	{
		address_book_id = document.getElementById('select_address').options[document.getElementById('select_address').selectedIndex].value;
	}

	document.getElementById("create_new_address_button_area").style.display="none";
	
	document.getElementById('address_book_area').innerHTML = 'loading...';

	var ajaxObj = new Class_Ajax();
	ajaxObj.data_obj.address_book_id = address_book_id;

	ajaxObj.SendRequest(g_current_general_url+'param=process_user_ajax&user_type_code='+user_type_code+'&operation=load_address_book&');
}
function Ajax_LoadAddressBook_TEST(user_type_code, force_create_new)
{
	var address_book_id;
	if(!force_create_new)
	{
		address_book_id = document.getElementById('select_address').options[document.getElementById('select_address').selectedIndex].value;
	}

	document.getElementById("create_new_address_button_area").style.display="none";

	document.getElementById('address_book_area').innerHTML = 'loading...';

	var ajaxObj = new Class_Ajax();
	ajaxObj.data_obj.address_book_id = address_book_id;

	ajaxObj.SendRequest(g_current_general_url+'param=process_user_ajax&user_type_code='+user_type_code+'&operation=load_address_book&');
}

function Ajax_LoadAddressBookHandler(address_book_table, address_book_id, new_address_select_box_html)
{
	if(address_book_id == '' || address_book_id == 'create_new')
	{
		document.getElementById("create_new_address_button_area").style.display="none";
	}
	else
	{
		document.getElementById("create_new_address_button_area").style.display="";//show
	}

	document.getElementById('address_select_box_area').innerHTML = new_address_select_box_html;
	
	document.getElementById('address_book_area').innerHTML = address_book_table;
}

function Ajax_DeleteAddressBookEntry(user_type_code, address_book_id)
{
	var ajaxObj = new Class_Ajax();
	ajaxObj.data_obj.address_book_id = address_book_id;
	ajaxObj.SendRequest(g_current_general_url+'param=process_user_ajax&user_type_code='+user_type_code+'&operation=delete_address_book_entry&');
}

function Ajax_DeleteAddressBookEntryHandler(user_type_code, deleted_succussfully, address_book_id)
{
	if(deleted_succussfully)
	{
		alert('Entry successfully deleted.');
		Ajax_LoadAddressBook(user_type_code, true);
		Ajax_ReloadAddressSelectBox(user_type_code);
	}
	else
	{
		alert('Could not delete entry! (missing/invalid: $address_book_id)');
	}
}

function Ajax_ReloadAddressSelectBox(user_type_code)
{
	var ajaxObj = new Class_Ajax();
	ajaxObj.SendRequest(g_current_general_url+'param=process_user_ajax&user_type_code='+user_type_code+'&operation=reload_address_select_box&');
}

function Ajax_ReloadAddressSelectBoxHandler(new_address_select_box_html)
{
	document.getElementById("address_select_box_area").innerHTML = new_address_select_box_html;
}

/*

function Ajax_SaveAddressBookChanges(user_type_code, address_book_id)
{
	var ajaxObj = new Class_Ajax();
	ajaxObj.data_obj.address_book_id = address_book_id;

	ajaxObj.SendRequest(g_current_general_url+'param=process_user_ajax&user_type_code='+user_type_code+'&operation=save_address_book_entry&');
}

function Ajax_SaveAddressBookChangesHandler(address_book_id)
{
	alert('Ajax_SaveAddressBookChangesHandler: '+address_book_id);
}

function Ajax_SubmitNewAddressBookEntry(user_type_code)
{
	var ajaxObj = new Class_Ajax();
	
	//ajaxObj.data_obj.address_book_id = address_book_id;

	ajaxObj.SendRequest(g_current_general_url+'param=process_user_ajax&user_type_code='+user_type_code+'&operation=submit_new_address_book_entry&');
}

function Ajax_SubmitNewAddressBookEntryHandler()
{
	alert('Ajax_SubmitNewAddressBookEntryHandler');
}
*/






















