$(function() {
  if(typeof(USFajaxBaseUrl) == "undefined")
    USFajaxBaseUrl = "http://217.111.11.68/wgzdvt/ajax/";
    
  if(typeof(USFbaseUrl) == "undefined")
    USFbaseUrl = "http://217.111.11.68/wgzdvt/";
  
  if(typeof(USFauthorizedUrl) == "undefined")
    USFauthorizedUrl = "";
    
  $("#q, #query").autocomplete({
  	source: function(request, response) {
  		$.ajax({
  			url: USFajaxBaseUrl+"get_search_dropdown.htn",
  			dataType: "jsonp",
  			data: {
  				q: request.term
  			},
  			jsonpCallback: 'c',
  			success: function(data) {
  				response(data)
  			}
  		})
  	},
  	minLength: 2,
  	select: function(event, ui) {
  		window.location.href = USFbaseUrl+'einzelwert.htn?'+USFauthorizedUrl+'i='+ui.item.value;
  		return(false);
  	},
  	open: function() {
  		$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
  	},
  	close: function() {
  		$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
  	},
  	focus: function(event, ui) {
  	  return(false);
  	}
  });
});

