function test() {
	alert('hello world');
}

$(document).ready(function() {
	function async_search(ret_html) {
		$('#member_list').html(ret_html);
		document.body.style.cursor = "";
	}

	$("#dosearch").click(function(){
		var curs = document.body.style.cursor;
		document.body.style.cursor = "wait";
		$.post("http://www.triathlonireland.com/specfunc/search_members.php", {forename: $('#criteria_f').val(), surname: $('#criteria_s').val()}, async_search);
	});

	$("#add_member").click(function(){
		var str = "";
		$("#member_list_select option:selected").each(function () {
			str = $("#ti_numbers").val();
			if(str.length > 0)
				str = str+", ";
			if($(this).text().length>0) {
				$("#ti_numbers").val(str+$(this).val());
			}
		});
	});

	function async_results(ret_html) {
		$('#results_block').html(ret_html);
		document.body.style.cursor = "";
	}

	$("#show_results").click(function(){
		var ti_numbers = $('#ti_numbers').val();
		document.body.style.cursor = "wait";
		if (ti_numbers.length>0) {
			$.post("http://www.triathlonireland.com/specfunc/show_member_results.php", {ti_nos: $('#ti_numbers').val()}, async_results);
		}
		else {
			alert('You must enter some Triathlon Ireland numbers first.');
		}
	});

});