$(function(){ 

	// make sure the user can't use the enter key to submit the form
	$('#quicksearch').parent('form').keypress(function(e){
		if(e.which == 13) { return false; }
	});
	
	$('#quicksearch').empty();
	
	// bind the autocomplete
	$('#quicksearch').autocomplete('/in/autocomplete.cfm', {
		selectFirst:false,
		minChars:2,
		matchContains:true,
		cacheLength:1,
		formatResult: formatResult,
		formatItem: formatItem
		})
	.result(function(event, data, formatted) {
		//if (data)
		//	$(this).parent().next().find("input").val(data[1]);
		$(this).siblings(':input[name=catID]').val(data[0]);
		$(this).siblings('div[name=town]').show();
		//$(this).siblings('div > :submit').bind('click', function(){ $(this).parent().parent('form').submit(); return true; });
		//$('#quicksearch').parent('form').bind('click', function(){ return true; });
		//$(this).parent('form').submit();
	});


});

function formatItem(row) { return row[1]; }
function formatResult(row) { return row[1]; }

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=498, height=495,left = 390,top = 337');");
}


