var version_Saf = navigator.appVersion.substring((navigator.appVersion.indexOf("Version/") + 8), navigator.appVersion.indexOf("Version/") + 13);
var version_IE = navigator.appVersion.substring((navigator.appVersion.indexOf("MSIE ") + 5), navigator.appVersion.indexOf("MSIE ") + 6);
//if(navigator.userAgent.indexOf("MSIE")>0||(navigator.userAgent.indexOf("Safari")>0&&parseInt(version)<5)){}else{
if((navigator.userAgent.indexOf("MSIE")>0&&parseInt(version_IE)<8)||(navigator.userAgent.indexOf("Safari")>0&&parseInt(version_Saf)<5)){}else{
/**
 * Provides suggestions for state names (USA).
 * @class
 * @scope public
 */
function RemoteStateSuggestions_aut() {

    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_aut.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var oHttp = this.http;
                                                             
    //if there is already a live request, cancel it
    if (oHttp.readyState != 0) {
        oHttp.abort();
    }                 
    
    //build the URL
    var sURL = "sucheaut.php?userInput=" + encodeURIComponent(oAutoSuggestControl.textbox.value);
    //var sURL = "sucheaut.php?userInput=" + oAutoSuggestControl.textbox.value;
    if(typeof SID != 'undefined') sURL += (sURL.indexOf('?')>0 ? '&' : '?') + SID;
    //open connection to states.txt file
    oHttp.open("get", sURL , true);
    oHttp.onreadystatechange = function () {
        if (oHttp.readyState == 4) {
            //evaluate the returned text JavaScript (an array)
            var aSuggestions = eval(convert_codes(oHttp.responseText));
        
            //provide suggestions to the control
            oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
        }    
    };
    //alert (aSuggestions);
    oHttp.send(null);
    
};





function RemoteStateSuggestions_tit() {
    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.
 */
 
//Hier muss das Argument 'aut' an die Funktion uebergeben werden, falls 'aut' existiert soll eine andere 
//Get-Variable angehängt werden, dann erfolgt in suchetit_bva.php eine andere Abfrage

RemoteStateSuggestions_tit.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var oHttp = this.http;

    //funktioniert nicht
    //if(aut){alert(aut);}
    //funktioniert auch nicht
    //alert("Kacke");
                                                             
    //if there is already a live request, cancel it
    if (oHttp.readyState != 0) {
        oHttp.abort();
    }                 
    
    //build the URL
    var sURL = "suchetit.php?userInput=" + encodeURIComponent(oAutoSuggestControl.textbox.value);
    //var sURL = "autosuggest1.php?userInput=" + oAutoSuggestControl.textbox.value;
    if(typeof SID != 'undefined') sURL += (sURL.indexOf('?')>0 ? '&' : '?') + SID;
    //open connection to states.txt file
    oHttp.open("get", sURL , true);
    oHttp.onreadystatechange = function () {
        if (oHttp.readyState == 4) {
            //evaluate the returned text JavaScript (an array)
            var aSuggestions = eval(convert_codes(oHttp.responseText));
            //alert (aSuggestions);
            //aSuggestions = convert_code(aSuggestions);
            //provide suggestions to the control
            oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
        }    
    };
    oHttp.send(null);
    
};


function RemoteStateSuggestions_isbn() {

    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_isbn.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/,
                                                          bTypeAhead /*:boolean*/) {
    var oHttp = this.http;
                                                             
    //if there is already a live request, cancel it
    if (oHttp.readyState != 0) {
        oHttp.abort();
    }                 
    
    //build the URL
    var sURL = "sucheisbn.php?userInput=" + encodeURIComponent(oAutoSuggestControl.textbox.value);
    //var sURL = "autosuggest1.php?userInput=" + oAutoSuggestControl.textbox.value;
    if(typeof SID != 'undefined') sURL += (sURL.indexOf('?')>0 ? '&' : '?') + SID;
    //open connection to states.txt file
    oHttp.open("get", sURL , true);
    oHttp.onreadystatechange = function () {
        if (oHttp.readyState == 4) {
            //evaluate the returned text JavaScript (an array)
            var aSuggestions = eval(oHttp.responseText);
        
            //provide suggestions to the control
            oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
        }    
    };
    oHttp.send(null);
    
};

function RemoteStateSuggestions_search() {

    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_search.prototype.requestSuggestions = function (oAutoSuggestControl /*:AutoSuggestControl*/, bTypeAhead /*:boolean*/) {
    //alert("request");
    var oHttp = this.http;
                                                             
    //if there is already a live request, cancel it
    if (oHttp.readyState != 0) {
        oHttp.abort();
    }                 
    
    //build the URL
    var sURL = "findaut.php?userInput=" + encodeURIComponent(oAutoSuggestControl.textbox.value);
    //var sURL = "autosuggest1.php?userInput=" + oAutoSuggestControl.textbox.value;
    if(typeof SID != 'undefined') sURL += (sURL.indexOf('?')>0 ? '&' : '?') + SID;
    //alert (sURL);
    
    //open connection to states.txt file
    oHttp.open("get", sURL , true);
    oHttp.onreadystatechange = function () {
        if (oHttp.readyState == 4) {
            //evaluate the returned text JavaScript (an array)
            var aSuggestions = eval(oHttp.responseText);
        
            //provide suggestions to the control
            oAutoSuggestControl.autosuggest(aSuggestions, bTypeAhead);        
        }    
    };
    oHttp.send(null);
    
};


function str_replace(search, replace, subject) {
  return subject.split(search).join(replace);
}

function convert_codes(titel){
  titel = str_replace("&#333;", "o", titel);
  titel = str_replace("&#363;", "u", titel);
  titel = str_replace("&#332;", "O", titel);
  return titel;
}
//alert("Ende");
}
