
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function RemoteStateSuggestions() {

    if (typeof XMLHttpRequest != "undefined") {
        this.http = new XMLHttpRequest();
    } else if (typeof ActiveXObject != "undefined") {
        this.http = new ActiveXObject("MSXML2.XmlHttp");
    } else {
        alert("No XMLHttpRequest object available. This functionality will not work.");
    }

}

/**
 * Request suggestions for the given autosuggest control. 
 * @scope protected
 * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
 */
RemoteStateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) 
{

    var oHttp = this.http;
    var taal =0;
                                                             
    //if there is already a live request, cancel it
    if (oHttp.readyState != 0) 
    {
        oHttp.abort();
    }                 
    
    taal = haal_taal_op();
  
    
    if (taal==1)
    {
       //ned - pools
       var sURL = "vulaan/vulaan_ned.php?woord=" + encodeURIComponent(oAutoSuggestControl.textbox.value)+ "&cache_fix="+Math.random();
    }
    if (taal==2)
    {   
    	 // pools - ned
       var sURL = "vulaan/vulaan_pol.php?woord=" + encodeURIComponent(oAutoSuggestControl.textbox.value)+ "&cache_fix="+Math.random();
    }
    
    
    oHttp.open("get", sURL , true);
    oHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
    oHttp.setRequestHeader("charset", "utf-8");
    oHttp.onreadystatechange = function () {
        if (oHttp.readyState == 4) {
        	 //alert(oHttp.getAllResponseHeaders());

            //evaluate the returned text JavaScript (an array)
            var aSuggestions = eval(oHttp.responseText);
        
            //provide suggestions to the control
            oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
        }    
    };
    oHttp.send(null);
    

};