var suggestion = {
  timer: 0,
  mapCode: '',
  inputString: ''
};

suggestion.prototype = {}

suggestion.clearInput = function(obj, text) {
  if (obj.value == text)
    obj.value = '';  
}

suggestion.lookup = function(mapCode, inputString) {
  clearTimeout(this.timer);
  this.timer = setTimeout("suggestion.callSugg()", 300);
  this.mapCode = mapCode;
  this.inputString = inputString;  
}

suggestion.callSugg = function()
{
  if(this.inputString.length == 0) {
    $('#suggestions').fadeOut(); // Hide the suggestions box
 } else {  
  $.post(config.file_ajax, {data: ""+this.inputString+"", action: 'search', mapCode: this.mapCode}, function(data) { // Do an AJAX call    
     pos = $("#searchInput").offset();
     suggestionHeight = $('#suggestions').height();

     $('#suggestions').fadeIn(); // Show the suggestions box
     $('#suggestions').html(data); // Fill the suggestions box
     suggestionHeight = $('#suggestions').height();
//     alert(suggestionHeight);
     suggestionTop = pos.top - suggestionHeight;
     $('#suggestions').css({ 'top': suggestionTop+'px', 'left': pos.left+'px'});     
  });  
 }
}

suggestion.clearInput = function (obj, text) {
  if (obj.value == text)
    obj.value = '';
}