function findValue(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	$("#startpt").val(sValue);
	
}

function findValue2(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	
	$("#startpt2").val(sValue);
	
	
}

function findValue3(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	$("#startpt3").val(sValue);
	
}

function findValue4(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	$("#startpt4").val(sValue);
	
}

function findValueend(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	$("#endpt").val(sValue);
	
}

function findValueend2(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	$("#endpt2").val(sValue);
	
}

function findValueend3(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	$("#endpt3").val(sValue);
	
}

function findValueend4(li) {
	if( li == null ) return alert("Nincs találat");
	if( !!li.extra ) var sValue = li.extra[0];
	else var sValue = li.selectValue;
	$("#endpt4").val(sValue);
	
}

function selectItemend(li) {
	findValueend(li);
}

function selectItemend2(li) {
	findValueend2(li);
}

function selectItemend3(li) {
	findValueend3(li);
}

function selectItemend4(li) {
	findValueend4(li);
}

function selectItem(li) {
	findValue(li);
}

function selectItem2(li) {
	findValue2(li);
}

function selectItem3(li) {
	findValue3(li);
}

function selectItem4(li) {
	findValue4(li);
}

function formatItemend(row) {
	return row[0]; 
	
}

function formatItemend2(row) {
	return row[0]; 
	
}

function formatItemend3(row) {
	return row[0]; 
	
}

function formatItemend4(row) {
	return row[0]; 
	
}

function formatItem(row) {
	return row[0]; 
	
}

function formatItem2(row) {
	return row[0]; 
	
}

function formatItem3(row) {
	return row[0]; 
	
}

function formatItem4(row) {
	return row[0]; 
	
}


$(document).ready(function() {
	$("#CityAjax").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem,
			onFindValue:findValue,
			formatItem:formatItem,
			autoFill:true
		}
	);

	$("#CityAjax2").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem2,
			onFindValue:findValue2,
			formatItem:formatItem2,
			autoFill:true
		}
	);	

	$("#CityAjax3").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem3,
			onFindValue:findValue3,
			formatItem:formatItem3,
			autoFill:true
		}
	);	

	$("#CityAjax4").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItem4,
			onFindValue:findValue4,
			formatItem:formatItem4,
			autoFill:true
		}
	);	
	
	$("#CityAjaxend").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItemend,
			onFindValue:findValueend,
			formatItem:formatItemend,
			autoFill:true
		}
	);
	
	$("#CityAjaxend2").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItemend2,
			onFindValue:findValueend2,
			formatItem:formatItemend2,
			autoFill:true
		}
	);
	
		$("#CityAjaxend3").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItemend3,
			onFindValue:findValueend3,
			formatItem:formatItemend3,
			autoFill:true
		}
	);
	
		$("#CityAjaxend4").autocomplete(
		"citysearch.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			onItemSelect:selectItemend4,
			onFindValue:findValueend4,
			formatItem:formatItemend4,
			autoFill:true
		}
	);
	

});

