jQuery(document).ready(function($) {
	// request list of properties with given postcode
	function postcodeFootprint() {
		var post_code = $("#txtPostCodeLookup").val();
		if (post_code) {
			$("#tdPostCodeFootprint").html("Loading...").css({visible: true});
			$.post("ajax.php", {action: 'post_code_footprint', post_code: post_code}, function(responseText) {
				$("#tdPostCodeFootprint").html(responseText);
			});
		}
	}

	// note that we use $.live as the button and form field may be created later when the tab is loaded
	$("#btnPostCodeLookup").live("click", function(event) {
		event.preventDefault();
		postcodeFootprint();
	});
	
	
	$("#txtPostCodeLookup").live("keypress", function(event) {
		if (event.keyCode == 13) {
			event.preventDefault();
			$("#btnPostCodeLookup").click();
		}
	});
});
