function autocompleter(text_field_id)
{
	this.field = $('#'+text_field_id);
	
	this.options =
	{
		minChars: 1,
		max: 5,
		selectFirst: false
	};
	
	// ------------------
	
	this.initialise = function()
	{
		this.area = this.get_area();
	
		this.use_temp_data();
	
		/*
		if (this.area) this.use_local_data();	// Faster local data
		else this.use_remote_data();			// Slower remote data
		*/
	};
	
	this.get_area = function()
	{
		// Retreive the 'query string' from the script element
		// E.g: autocompleter.js?Birmingham
		var script_src = $('script[src*="autocompleter.js"]').attr('src');
		var area = script_src.match(/\.js\?(.+)?$/)[1];
		return area;
	};
	
	this.use_temp_data = function()
	{
		var self = this;
		$.getJSON('../js/area_json/temp.js', function(json)
		{
			self.field.autocomplete(json, self.options);
		});
	},
	
	this.use_local_data = function()
	{
		var self = this;
		$.getJSON('../js/area_json/'+this.area.toLowerCase()+'.js', function(json)
		{
			self.field.autocomplete(json, self.options);
		});
	};
	
	this.use_remote_data = function()
	{
		self.options['formatItem'] = function(row)
		{
			return row[0] + ' <span>'+row[1]+'</span>';
		}
	
		this.field.autocomplete('../../autocompleter.pl', self.options);
	};
}