/*** Used for Personsearch (TODO: move/combine so that we can use it for coursesearch also) ***/
/*** Requires JQuery autocomplete plugin, bundled with Vortex. ***/
function setAutoComplete(id, service, params, scope, sort, areacode, lang) {
  var p = {
    minChars: 2,
    selectFirst: true,
    max: 20,
    resultsBeforeScroll: 10
  };
  if (params) {
    $.extend(p, params);
  }
  var objId = '#' + id;
  var serviceUrl = '?action=autocomplete&service=' + service;
  if (scope != '') {
    serviceUrl += '&scope=' + scope;
  }
  if (sort != '') {
    serviceUrl += '&sort=' + sort;
  }
  if (areacode != '') {
    serviceUrl += '&areacode=' + areacode;
  }
  if (lang != '') {
    serviceUrl += '&lang=' + lang;
  }
  $(objId).autocomplete(serviceUrl, p);
};
