﻿function citySuggestions() {
    //nothing needed since the AJAX in the requestSuggestions will be creating our array
    //this suggestion array will return all possible values, regardless of other filters
}

citySuggestions.prototype.requestSuggestions = function(oAutoSuggestControl, bTypeAhead) {
    var aSuggestions = [];
    var sTextboxValue = oAutoSuggestControl.textbox.value;
    //alert("global\n" + $F('showGlobal') + "fieldName\n" + oAutoSuggestControl.textbox.id + "givenName\n" + $F('givenName') + "surName\n" + $F('surName') + "jobTitle\n" + $F('jobTitle') + "organization\n" + $F('organization') + "organizationType\n" + $F('organizationType') + "contactType\n" + $F('contactType') + "contactPHDept\n" + $F('contactPHDept') + "validated\n" + $F('validated') + "GUID\n" + $F('GUID'))
    if(sTextboxValue.length > 0)
    {
        oAutoSuggestControl.textbox.ajaxRequest = new Ajax.Request('autoCompleteJSON.aspx',
        {
            method:'get',
            parameters: {
                fieldValue: sTextboxValue
                },
            onSuccess: function(transport)
            {
                aSuggestions = transport.responseText.evalJSON();
                oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);
            },
            onFailure: function()
            {
                alert('Something went wrong...')
            }
        });
    }
}