function formatDestination(val, inList) {
		var dest = val.toString().split(";");
		if(dest[6] == '2') {
			var str = dest[0] + ", " + dest[1] + ", " + dest[5] + " (" + dest[2] + ")";
			return (inList) ? "<img src='whisper_1_0/flags/" + dest[4] + ".gif'/> " + str : str;
		} else if(dest[6] == '1') {
			var str = dest[0] + ", " + dest[1] + " (" + dest[2] + ")";
			return (inList) ? "<img src='whisper_1_0/space.gif'/>" + str : str;
		} else {
			var str = dest[0] + ", " + dest[5] + " (" + dest[3] + ")";
			return (inList) ? "<img src='whisper_1_0/flags/" + dest[4] + ".gif'/> " + str : str;
		}
}

  function formatAirport(val, inList) {
		var dest = val.toString().split(";");
		if(dest[dest.length-1] == '2') {
			var str = dest[1] + ", " + dest[2] + ", " + dest[5] + " (" + dest[0] + ")";
			return (inList) ? "<img src='whisper_1_0/flags/" + dest[4] + ".gif'/> " + str : str;
		} else if(dest[dest.length-1] == '1') {
			var str = dest[1] + ", " + dest[2] + " (" + dest[0] + ")";
			return (inList) ? "<img src='whisper_1_0/space.gif'/>" + str : str;
		} else {
			var str = dest[1] + ", " + dest[5] + " (" + dest[3] + ")";
			return (inList) ? "<img src='whisper_1_0/flags/" + dest[4] + ".gif'/> " + str : str;
		}
}

function formatCity(val, inList) {
		var dest = val.toString().split(";");
		var str = dest[1] + ", " + dest[3] + " (" + dest[0] + ")";
		return (inList) ? "<img src='whisper_1_0/flags/" + dest[2] + ".gif'/> " + str : str;
}
	
$(document).ready(function(){
	$("#airportcs").autocomplete("whisper_1_0/whisper_airport.php?lng=cs", {
		  formatItem: function(value, i, n, search) {
		  	return formatAirport(value, true)
		  },
		  formatResult: function(value) {
				return formatAirport(value, false);
		  },
		  matchSubset: false,
		  minChars: 3,
			max: 30,
			//cacheLength: 1,
			width: 300
	});
	
	$("#airporten").autocomplete("whisper_1_0/whisper_airport.php?lng=cs", {
		  formatItem: function(value, i, n, search) {
		  	return formatAirport(value, true)
		  },
		  formatResult: function(value) {
				return formatAirport(value, false);
		  },
		  matchSubset: false,
		  minChars: 3,
			max: 30,
			//cacheLength: 1,
			width: 300
	});
	
	$("#hotelcs").autocomplete("whisper_1_0/whisper_city.php?lng=cs", {
		  formatItem: function(value, i, n, search) {
		  	return formatCity(value, true)
		  },
		  formatResult: function(value) {
				return formatCity(value, false);
		  },
		  matchSubset: false,
		  minChars: 3,
			max: 30,
			//cacheLength: 1,
			width: 300
	});

	$("#hotelen").autocomplete("whisper_1_0/whisper_city.php?lng=cs", {
		  formatItem: function(value, i, n, search) {
		  	return formatCity(value, true)
		  },
		  formatResult: function(value) {
				return formatCity(value, false);
		  },
		  matchSubset: false,
		  minChars: 3,
			max: 30,
			//cacheLength: 1,
			width: 300
	});		
	
});  
