function lookup_location(inputString, which_form, which_formNew) {
	
	var newURL = get_url();
	
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#lookup_'+which_form).hide();
	} 
	else {
		$.post(newURL+"includes/search_location.php", {queryString: inputString}, function(data) {
			if(data.length == 1 && data[0].results == 'none') {
				$('#lookup_'+which_form).hide();
			}
			else if(data.length > 0) {
				$('#lookup_'+which_form).show();
				var string = '';
				for (i=0; i<data.length; i++) {
					string = string+'<li onClick="fill_locationNew(\''+data[i].location+'\', \''+data[i].id+'\', \''+which_form+'\', \''+which_formNew+'\'); return false;">'+data[i].location+'</li>';
				}
				$('#auto_'+which_form).html(string);
				
			}
			else {
				$('#lookup_'+which_form).hide();
				//$('#hidden_location_id').val('');
			}
		}, "json");
	}
} // lookup

function fill_locationNew(str_location, str_townID, str_whichForm, str_whichFormNew) {
	//alert('#input'+str_whichFormNew);
	$('#input'+str_whichFormNew).val(str_location);
	setTimeout("$('#lookup_"+str_whichForm+"').hide();", 200);
}

function get_url() {
	newURL = window.location.protocol + "//" + window.location.host + "/";
	return newURL;
}
