(function($) {
	$.extend($.fn, {
		locationAutofill: function(fields) {
			this.each(function() {
				var country = $(this).find(fields.country);
				var city = $(this).find(fields.city);
				var region = $(this).find(fields.region);
				$(this).find(fields.postcode).bind("keyup change",function() {
					$.post("general/json/locationCheck.php",{
						country: country.val(),
						postcode: $(this).val()
					},function(response) {
						response.city === undefined || city.val() != "" || city.val(response.city);
						response.region === undefined || region.val() != "" || region.val(response.region);
					},"json");
				});
			});
		}
	});
})(jQuery);
