function ERMSRESTAutoSuggest(options) {
    if (typeof (XMLHttpRequest) == "undefined") {
        XMLHttpRequest = function () {
            try {
                return new ActiveXObject("MSXML2.XMLHTTP.6.0");
            } catch (e) {}
            try {
                return new ActiveXObject("MSXML2.XMLHTTP.3.0");
            } catch (e) {}
            try {
                return new ActiveXObject("MSXML2.XMLHTTP");
            } catch (e) {}
            try {
                return new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
            return null;
        };
    }
    try {
        document.execCommand('BackgroundImageCache', false);
    } catch (e) {}
    this._body = document.body;
    this._callback = options.callback;
    this._container = options.containerID ? document.getElementById(options.containerID) : null;
    this._databaseName = options.databaseName;
    this._dataLink = options.dataLink;
    this._delay = options.delay;
    this._dirty = false;
    this._enabled = false;
    this._hideSuggestionsText = options.hideSuggestionsText;
    this._iframe = null;
    this._menu = null;
    this._menuList = null;
    this._menuItem = null;
    this._prefix = null;
    this._qualifierMap = null;
    this._qualifierName = options.qualifierName;
    this._qualifierSelect = options.qualifierSelectID ? document.getElementById(options.qualifierSelectID) : null;
    this._queryInput = document.getElementById(options.queryInputID);
    this._requester = new XMLHttpRequest();
    this._showSuggestions = options.showSuggestionsID ? document.getElementById(options.showSuggestionsID) : null;
    this._showSuggestions.tabIndex = -1;
    this._timerID = null;
    if ("object" == typeof (options.filter)) {
        this._qualifierMap = new Array();
        for (var index in options.filter) this._qualifierMap[options.filter[index]] = true;
    }
    var _this = this;
    this.buildPath();
    if ((null == this._requester) || ("undefined" == typeof (this._requester))) return;
    if (!document.addEventListener) {
        document.addEventListener = function (type, listener, useCapture) {
            document.attachEvent("on" + type, listener);
        };
    }
    if (!document.handleMouseMove) {
        document.currentMouseX = 0;
        document.currentMouseY = 0;
        document.handleMouseMove = function (e) {
            document.currentMouseX = (window.event) ? window.event.screenX : e.screenX;
            document.currentMouseY = (window.event) ? window.event.screenY : e.screenY;
            return true;
        };
        document.addEventListener("mousemove", document.handleMouseMove, false);
    }
    var msieVersion = this.getMSIEVersion();
    if ((msieVersion >= 1) && (msieVersion <= 6)) {
        this._iframe = document.createElement("iframe");
        this._iframe.border = 1;
        this._iframe.frameBorder = "no";
        this._iframe.scrolling = "no";
        this._iframe.style.display = "block";
        this._iframe.style.position = "absolute";
        this._iframe.style.padding = "0px";
        this._iframe.style.visibility = "hidden";
        document.body.appendChild(this._iframe);
        var contentDocument = this._iframe.contentWindow.document;
        contentDocument.open();
        contentDocument.writeln("<html><head>");
        var stylesCollection = document.getElementsByTagName("style");
        for (var index = 0; index < stylesCollection.length; ++index) {
            var style = stylesCollection[index];
            contentDocument.writeln(style.outerHTML);
        }
        var linksCollection = document.getElementsByTagName("link");
        for (var index = 0; index < linksCollection.length; ++index) {
            var link = linksCollection[index];
            if ("text/css" == link.type) contentDocument.writeln(link.outerHTML);
        }
        contentDocument.writeln("</head><body style='margin: 0px;'></body></html>");
        contentDocument.close();
        this._body = contentDocument.body;
        if (!contentDocument.addEventListener) {
            contentDocument.addEventListener = function (type, listener, useCapture) {
                contentDocument.attachEvent("on" + type, listener);
            };
        }
        contentDocument.handleMouseMove = function (e) {
            document.currentMouseX = (window.event) ? window.event.screenX : e.screenX;
            document.currentMouseY = (window.event) ? window.event.screenY : e.screenY;
            return true;
        };
        contentDocument.addEventListener("mousemove", contentDocument.handleMouseMove, false);
    }
    this._queryInput.setAttribute("autocomplete", "off");
    if (this._queryInput.form) this._queryInput.form.setAttribute("autocomplete", "off");
    if (!this._queryInput.addEventListener) {
        var queryInputInput = this._queryInput;
        this._queryInput.addEventListener = function (type, listener, useCapture) {
            queryInputInput.attachEvent("on" + type, listener);
        };
    }
    if (!this._showSuggestions.addEventListener) {
        var showSuggestions = this._showSuggestions;
        this._showSuggestions.addEventListener = function (type, listener, useCapture) {
            showSuggestions.attachEvent("on" + type, listener);
        };
    }
    var delegateQueryInputBlur = function (e) {
            return _this.handleQueryInputBlur(e);
        };
    this._queryInput.addEventListener("blur", delegateQueryInputBlur, false);
    var delegateQueryInputDblClick = function (e) {
            return _this.handleQueryInputDblClick(e);
        };
    this._queryInput.addEventListener("dblclick", delegateQueryInputDblClick, false);
    var delegateQueryInputKeyDown = function (e) {
            return _this.handleQueryInputKeyDown(e);
        };
    this._queryInput.addEventListener("keydown", delegateQueryInputKeyDown, false);
    var delegateQueryInputKeyUp = function (e) {
            return _this.handleQueryInputKeyUp(e);
        };
    this._queryInput.addEventListener("keyup", delegateQueryInputKeyUp, false);
    var delegateQueryInputMove = function (e) {
            return _this.handleQueryInputMove(e);
        };
    this._queryInput.addEventListener("move", delegateQueryInputMove, false);
    var delegateQueryInputResize = function (e) {
            return _this.handleQueryInputResize(e);
        };
    this._queryInput.addEventListener("resize", delegateQueryInputResize, false);
    if (!window.addEventListener) {
        window.addEventListener = function (type, listener, useCapture) {
            window.attachEvent("on" + type, listener);
        };
    }
    if (this._qualifierSelect) {
        if (!this._qualifierSelect.addEventListener) {
            var qualifierSelect = this._qualifierSelect;
            this._qualifierSelect.addEventListener = function (type, listener, useCapture) {
                qualifierSelect.attachEvent("on" + type, listener);
            };
        }
        var delegateQualifierSelectChange = function (e) {
                return _this.handleQualifierSelectChange(e);
            };
        this._qualifierSelect.addEventListener("change", delegateQualifierSelectChange, false);
    }
    var delegateResize = function (e) {
            _this.handleResize(e);
        };
    window.addEventListener("resize", delegateResize, false);
    var delegateShowSuggestionsFocus = function (e) {
            return _this.handleShowSuggestionsFocus(e);
        };
    this._showSuggestions.addEventListener("focus", delegateShowSuggestionsFocus, false);
    this._showSuggestions.addEventListener("click", delegateShowSuggestionsFocus, false);
    var delegateShowSuggestionsMouseOver = function (e) {
            return _this.handleShowSuggestionsMouseOver(e);
        };
    this._showSuggestions.addEventListener("mouseover", delegateShowSuggestionsMouseOver, false);
    var delegateShowSuggestionsMouseOut = function (e) {
            return _this.handleShowSuggestionsMouseOut(e);
        };
    this._showSuggestions.addEventListener("mouseout", delegateShowSuggestionsMouseOut, false);
    if (options.enabled) this.enable();
}
ERMSRESTAutoSuggest.prototype.activateMenu = function () {
    this.deactivateMenu();
    var left = 0;
    var top = 0;
    var object = this._container;
    while (object) {
        left += object.offsetLeft;
        top += object.offsetTop;
        object = object.offsetParent;
    }
    var contentDocument = this._iframe ? this._iframe.contentWindow.document : document;
    this._menu = contentDocument.createElement("div");
    this._menu.className = "AutoSuggestMenu";
    this._menu.style.display = "block";
    this._menu.style.overflow = "hidden";
    this._menu.style.zoom = 1;
    this._menu.previousMouseX = document.currentMouseX;
    this._menu.previousMouseY = document.currentMouseY;
    if (this._iframe) {
        this._iframe.height = 1;
        this._iframe.width = 1;
        this._iframe.style.display = "block";
        this._iframe.style.left = (left).toString() + "px";
        this._iframe.style.position = "absolute";
        this._iframe.style.top = (top + this._container.offsetHeight - 1).toString() + "px";
        this._menu.style.minWidth = (this._container.offsetWidth).toString() + "px";
        var _this = this;
        this._menu.onresize = function (e) {
            if ((_this._iframe.height != _this._menu.offsetHeight) || (_this._iframe.width != _this._menu.offsetWidth)) {
                _this._iframe.height = _this._menu.offsetHeight;
                _this._iframe.width = _this._menu.offsetWidth;
            }
        };
    } else {
        this._menu.style.left = (left).toString() + "px";
        this._menu.style.minWidth = (this._container.offsetWidth).toString() + "px";
        this._menu.style.position = "absolute";
        this._menu.style.top = (top + this._container.offsetHeight - 1).toString() + "px";
    }
    var _this = this;
    this._menuList = contentDocument.createElement("ul");
    this._menu.appendChild(this._menuList);
    var p = contentDocument.createElement("p");
    var span = contentDocument.createElement("span");
    span.appendChild(contentDocument.createTextNode(this._hideSuggestionsText));
    span.title = this._hideSuggestionsText;
    span.style.cursor = "pointer";
    p.appendChild(span);
    this._menu.appendChild(p);
    this._menuList.onmousedown = function (e) {
        _this.handleMenuMouseDown(e);
    };
    this._menuList.onmousemove = function (e) {
        _this.handleMenuMouseOver(e);
    };
    this._menuList.onmouseover = function (e) {
        _this.handleMenuMouseOver(e);
    };
    this._menuList.onmouseout = function (e) {
        _this.handleMenuMouseOut(e);
    };
    span.onmousedown = function (e) {
        _this._showSuggestions.style.visibility = "visible";
        _this._showSuggestions.value = "";
        _this.setCookie(false);
    };
    this._body.appendChild(this._menu);
    if (this._iframe) this._iframe.style.visibility = "visible";
};
ERMSRESTAutoSuggest.prototype.adjustLayout = function () {
    if (this._menu) {
        var left = 0;
        var top = 0;
        var object = this._container;
        while (object) {
            left += object.offsetLeft;
            top += object.offsetTop;
            object = object.offsetParent;
        }
        this._menu.style.left = (left).toString() + "px";
        this._menu.style.top = (top + this._container.offsetHeight - 1).toString() + "px";
    }
    return true;
};
ERMSRESTAutoSuggest.prototype.buildPath = function () {
    if (this._qualifierMap) {
        if (!this._qualifierMap[this._qualifierName]) {
            this._path = null;
            return;
        }
    }
    //this._path = "/ERMSDaemon/REST/" + this._dataLink + "/" + this._databaseName + "/" + this._qualifierName + "/suggest";
    this._path = "/webservices/polaris_api.php";
};
ERMSRESTAutoSuggest.prototype.changeQualifier = function (qualifierName) {
    this._qualifierName = qualifierName;
    this.buildPath();
};
ERMSRESTAutoSuggest.prototype.deactivateMenu = function () {
    this._requester.abort();
    if (this._menu) {
        if (this._menuItem) {
            this._menuItem.id = null;
            this._menuItem = null;
        }
        this._body.removeChild(this._menu);
        this._menu = null;
        this._menuList = null;
        if (this._iframe) {
            this._iframe.style.visibility = "hidden";
            this._iframe.style.display = "none";
        }
    }
    this._dirty = false;
};
ERMSRESTAutoSuggest.prototype.disable = function () {
    this._showSuggestions.style.visibility = "hidden";
    this._showSuggestions.value = "1";
    this._enabled = false;
};
ERMSRESTAutoSuggest.prototype.enable = function () {
    if (this.getCookie()) {
        this._showSuggestions.value = "1";
        this._showSuggestions.style.visibility = "hidden";
    } else {
        this._showSuggestions.value = "";
        this._showSuggestions.style.visibility = "visible";
    }
    this._enabled = true;
};
ERMSRESTAutoSuggest.prototype.getCookie = function () {
    var value = true;
    var cookies = document.cookie.split("; ");
    for (var index = 0; index < cookies.length; index++) {
        var crumb = cookies[index].split("=");
        if ("AutoSuggest" == crumb[0]) {
            switch (unescape(crumb[1])) {
            case "0":
            case "false":
                value = false;
                break;
            }
        }
    }
    return value;
};
ERMSRESTAutoSuggest.prototype.getMSIEVersion = function () {
    var userAgent = window.navigator.userAgent;
    var msie = userAgent.indexOf("MSIE");
    if (msie > 0) return parseInt(userAgent.substring(msie + 5, userAgent.indexOf(".", msie)));
    return 0;
};
ERMSRESTAutoSuggest.prototype.handleQualifierSelectChange = function (e) {
    var srcElement = (window.event) ? window.event.srcElement : e.srcElement;
    var qualifierName = srcElement.options[srcElement.selectedIndex].value;
    this.changeQualifier(qualifierName);
    return true;
};
ERMSRESTAutoSuggest.prototype.handleQueryInputBlur = function (e) {
    this.deactivateMenu();
    return true;
};
ERMSRESTAutoSuggest.prototype.handleQueryInputDblClick = function (e) {
    this.updatePrefix();
    return true;
};
ERMSRESTAutoSuggest.prototype.handleQueryInputKeyDown = function (e) {
    var keyCode = (window.event) ? window.event.keyCode : e.keyCode;
    var bubble = true;
    if (null == this._menu) return bubble;
    switch (keyCode) {
    case 13:
        {
            var fireCallback = false;
            if (this._menuItem) {
                if (this._menuItem.innerText) this._queryInput.value = this._menuItem.innerText;
                else if (this._menuItem.textContent) this._queryInput.value = this._menuItem.textContent;
                if (this._callback) fireCallback = true;
            }
            this.deactivateMenu();
            if (fireCallback) {
                this._callback(this._qualifierName);
                bubble = false;
            }
        }
        break;
    case 27:
        this.deactivateMenu();
        bubble = false;
        break;
    case 38:
        {
            if (this._menu) {
                this._menu.previousMouseX = document.currentMouseX;
                this._menu.previousMouseY = document.currentMouseY;
                if (this._menuItem) {
                    this._menuItem.id = null;
                    this._menuItem = this._menuItem.previousSibling;
                } else {
                    this._menuItem = this._menu.firstChild.lastChild;
                }
                if (this._menuItem) {
                    this._menuItem.id = "AutoSuggestHighlight";
                    if (this._menuItem.innerText) this._queryInput.value = this._menuItem.innerText;
                    else if (this._menuItem.textContent) this._queryInput.value = this._menuItem.textContent;
                } else {
                    this._queryInput.value = this._prefix;
                }
            }
            bubble = false;
        }
        break;
    case 40:
        {
            if (this._menu) {
                this._menu.previousMouseX = document.currentMouseX;
                this._menu.previousMouseY = document.currentMouseY;
                if (this._menuItem) {
                    this._menuItem.id = null;
                    this._menuItem = this._menuItem.nextSibling;
                } else {
                    this._menuItem = this._menu.firstChild.firstChild;
                }
                if (this._menuItem) {
                    this._menuItem.id = "AutoSuggestHighlight";
                    if (this._menuItem.innerText) this._queryInput.value = this._menuItem.innerText;
                    else if (this._menuItem.textContent) this._queryInput.value = this._menuItem.textContent;
                } else {
                    this._queryInput.value = this._prefix;
                }
            }
            bubble = false;
        }
        break;
    }
    return bubble;
};
ERMSRESTAutoSuggest.prototype.handleQueryInputKeyUp = function (e) {
    var keyCode = (window.event) ? window.event.keyCode : e.keyCode;
    var bubble = true;
    if (null != this._timerID) {
        clearTimeout(this._timerID);
        this._timerID = null;
    }
    switch (keyCode) {
    case 13:
        this.deactivateMenu();
        bubble = false;
        break;
    case 9:
    case 27:
        this.deactivateMenu();
        bubble = false;
        break;
    case 38:
    case 40:
        bubble = false;
        break;
    default:
        this.updatePrefix();
        break;
    }
    return bubble;
};
ERMSRESTAutoSuggest.prototype.handleQueryInputMove = function (e) {
    return this.adjustLayout();
};
ERMSRESTAutoSuggest.prototype.handleQueryInputResize = function (e) {
    return this.adjustLayout();
};
ERMSRESTAutoSuggest.prototype.handleMenuMouseDown = function (e) {
    if (this._menuItem) {
        if (this._menuItem.innerText) this._queryInput.value = this._menuItem.innerText;
        else if (this._menuItem.textContent) this._queryInput.value = this._menuItem.textContent;
        this._menuItem.id = null;
        this._menuItem = null;
    }
    if (this._callback) this._callback(this._qualifierName);
    else if (this._queryInput.form) this._queryInput.form.submit();
    return true;
};
ERMSRESTAutoSuggest.prototype.handleMenuMouseOver = function (e) {
    if (this._iframe) {
        if (!e) e = this._iframe.contentWindow.event;
    } else {
        if (!e) e = window.event;
    }
    if (!this._menu) return true;
    var screenX = e.screenX;
    var screenY = e.screenY;
    if ((screenX == this._menu.previousMouseX) && (screenY == this._menu.previousMouseY)) return true;
    this._menu.previousMouseX = screenX;
    this._menu.previousMouseY = screenY;
    var srcElement = e.srcElement;
    if (typeof (srcElement) != "object") {
        srcElement = e.target;
        while (srcElement.nodeType != srcElement.ELEMENT_NODE) srcElement = srcElement.parentNode;
    }
    if (srcElement) {
        if ("span" == srcElement.nodeName.toLowerCase()) srcElement = srcElement.parentNode;
    }
    if ("li" == srcElement.nodeName.toLowerCase()) {
        if (this._menuItem) {
            this._menuItem.id = null;
            this._menuItem = null;
        }
        if (srcElement) {
            this._menuItem = srcElement;
            this._menuItem.id = "AutoSuggestHighlight";
        }
    }
    return true;
};
ERMSRESTAutoSuggest.prototype.handleMenuMouseOut = function (e) {
    if (this._iframe) {
        if (!e) e = this._iframe.contentWindow.event;
    } else {
        if (!e) e = window.event;
    }
    if (this._menu.previousMouseX && this._menu.previousMouseY) {
        var screenX = e.screenX;
        var screenY = e.screenY;
        if ((screenX == this._menu.previousMouseX) && (screenY == this._menu.previousMouseY)) return true;
        this._menu.previousMouseX = screenX;
        this._menu.previousMouseY = screenY;
    }
    if (this._menuItem) {
        this._menuItem.id = null;
        this._menuItem = null;
        this._menu.previousMouseX = 0;
        this._menu.previousMouseY = 0;
    }
    return true;
};
ERMSRESTAutoSuggest.prototype.handleReadyStateChange = function (e) {
    if (!this._dirty) return;
    if ((4 /*READYSTATE_COMPLETE*/ == this._requester.readyState) && (200 /*HTTP_STATUS_OK*/ == this._requester.status)) {
        var content = eval(this._requester.responseText);
        if ("object" != typeof (content)) return;
        if (2 != content.length) this.deactivateMenu();
        else if (0 == content[1].length) this.deactivateMenu();
        else {
            this.activateMenu();
            var contentDocument = this._iframe ? this._iframe.contentWindow.document : document;
            var prefix = content[0];
            for (index = 0; index < content[1].length; ++index) {
                var li = this.makeListItem(contentDocument, prefix, content[1][index]);
                this._menuList.appendChild(li);
            }
            this._menuList.appendChild(li);
            if (this._menu.offsetWidth < this._queryInput.offsetWidth) this._menu.style.width = (this._queryInput.offsetWidth).toString() + "px";
        }
    }
};
ERMSRESTAutoSuggest.prototype.handleShowSuggestionsFocus = function (e) {
    this._queryInput.focus();
    this._showSuggestions.style.visibility = "hidden";
    this._showSuggestions.value = "1";
    this.setCookie(true);
    this.updatePrefix();
    return true;
};
ERMSRESTAutoSuggest.prototype.handleShowSuggestionsMouseOver = function (e) {
    this._showSuggestions.className = "AutoSuggestShowHot";
    return true;
};
ERMSRESTAutoSuggest.prototype.handleShowSuggestionsMouseOut = function (e) {
    this._showSuggestions.className = "AutoSuggestShowCold";
    return true;
};
ERMSRESTAutoSuggest.prototype.handleResize = function (e) {
    return this.adjustLayout();
};
ERMSRESTAutoSuggest.prototype.handleTimeout = function (e) {
    this._requester.abort();
    var _this = this;
    this._requester.onreadystatechange = function () {
        _this.handleReadyStateChange();
    };
    if (0 == this._queryInput.value.length) {
        this.deactivateMenu();
    } else {
        var url = this._path + "?q=" + encodeURIComponent(this._queryInput.value);
        this._prefix = this._queryInput.value;
        this._menuItem = null;
        this._requester.open("GET", url, true);
        this._requester.send(null);
    }
};
ERMSRESTAutoSuggest.prototype.isAccent = function (codePoint) {
    if (codePoint <= 3547) {
        if (codePoint >= 3547) return true;
        if (codePoint <= 2748) {
            if (codePoint >= 2748) return true;
            if (codePoint <= 2307) {
                if (codePoint >= 2305) return true;
                if (codePoint <= 1630) {
                    if (codePoint >= 1611) return true;
                    if (codePoint <= 1471) {
                        if (codePoint >= 1471) return true;
                        if (codePoint <= 879) {
                            if (codePoint >= 838) return true;
                            if (codePoint <= 834) {
                                if (codePoint >= 834) return true;
                                if ((codePoint >= 768) && (codePoint <= 831)) return true;
                            }
                        } else {
                            if (codePoint <= 1469) {
                                if (codePoint >= 1425) return true;
                                if ((codePoint >= 1155) && (codePoint <= 1161)) return true;
                            }
                        }
                    } else {
                        if (codePoint <= 1479) {
                            if (codePoint >= 1479) return true;
                            if (codePoint <= 1477) {
                                if (codePoint >= 1476) return true;
                                if ((codePoint >= 1473) && (codePoint <= 1474)) return true;
                            }
                        } else {
                            if ((codePoint >= 1552) && (codePoint <= 1562)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 1773) {
                        if (codePoint >= 1770) return true;
                        if (codePoint <= 1764) {
                            if (codePoint >= 1758) return true;
                            if (codePoint <= 1756) {
                                if (codePoint >= 1750) return true;
                                if ((codePoint >= 1648) && (codePoint <= 1648)) return true;
                            }
                        } else {
                            if ((codePoint >= 1767) && (codePoint <= 1768)) return true;
                        }
                    } else {
                        if (codePoint <= 1968) {
                            if (codePoint >= 1958) return true;
                            if (codePoint <= 1866) {
                                if (codePoint >= 1840) return true;
                                if ((codePoint >= 1809) && (codePoint <= 1809)) return true;
                            }
                        } else {
                            if ((codePoint >= 2027) && (codePoint <= 2035)) return true;
                        }
                    }
                }
            } else {
                if (codePoint <= 2531) {
                    if (codePoint >= 2530) return true;
                    if (codePoint <= 2492) {
                        if (codePoint >= 2492) return true;
                        if (codePoint <= 2388) {
                            if (codePoint >= 2385) return true;
                            if (codePoint <= 2381) {
                                if (codePoint >= 2366) return true;
                                if ((codePoint >= 2364) && (codePoint <= 2364)) return true;
                            }
                        } else {
                            if (codePoint <= 2435) {
                                if (codePoint >= 2433) return true;
                                if ((codePoint >= 2402) && (codePoint <= 2403)) return true;
                            }
                        }
                    } else {
                        if (codePoint <= 2509) {
                            if (codePoint >= 2509) return true;
                            if (codePoint <= 2504) {
                                if (codePoint >= 2503) return true;
                                if ((codePoint >= 2494) && (codePoint <= 2500)) return true;
                            }
                        } else {
                            if ((codePoint >= 2519) && (codePoint <= 2519)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 2637) {
                        if (codePoint >= 2635) return true;
                        if (codePoint <= 2626) {
                            if (codePoint >= 2622) return true;
                            if (codePoint <= 2620) {
                                if (codePoint >= 2620) return true;
                                if ((codePoint >= 2561) && (codePoint <= 2563)) return true;
                            }
                        } else {
                            if ((codePoint >= 2631) && (codePoint <= 2632)) return true;
                        }
                    } else {
                        if (codePoint <= 2677) {
                            if (codePoint >= 2677) return true;
                            if (codePoint <= 2673) {
                                if (codePoint >= 2672) return true;
                                if ((codePoint >= 2641) && (codePoint <= 2641)) return true;
                            }
                        } else {
                            if ((codePoint >= 2689) && (codePoint <= 2691)) return true;
                        }
                    }
                }
            }
        } else {
            if (codePoint <= 3158) {
                if (codePoint >= 3157) return true;
                if (codePoint <= 2915) {
                    if (codePoint >= 2914) return true;
                    if (codePoint <= 2876) {
                        if (codePoint >= 2876) return true;
                        if (codePoint <= 2765) {
                            if (codePoint >= 2763) return true;
                            if (codePoint <= 2761) {
                                if (codePoint >= 2759) return true;
                                if ((codePoint >= 2750) && (codePoint <= 2757)) return true;
                            }
                        } else {
                            if (codePoint <= 2819) {
                                if (codePoint >= 2817) return true;
                                if ((codePoint >= 2786) && (codePoint <= 2787)) return true;
                            }
                        }
                    } else {
                        if (codePoint <= 2893) {
                            if (codePoint >= 2893) return true;
                            if (codePoint <= 2887) {
                                if (codePoint >= 2887) return true;
                                if ((codePoint >= 2878) && (codePoint <= 2884)) return true;
                            }
                        } else {
                            if ((codePoint >= 2902) && (codePoint <= 2903)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 3031) {
                        if (codePoint >= 3031) return true;
                        if (codePoint <= 3016) {
                            if (codePoint >= 3014) return true;
                            if (codePoint <= 3010) {
                                if (codePoint >= 3006) return true;
                                if ((codePoint >= 2946) && (codePoint <= 2946)) return true;
                            }
                        } else {
                            if ((codePoint >= 3021) && (codePoint <= 3021)) return true;
                        }
                    } else {
                        if (codePoint <= 3143) {
                            if (codePoint >= 3142) return true;
                            if (codePoint <= 3140) {
                                if (codePoint >= 3134) return true;
                                if ((codePoint >= 3073) && (codePoint <= 3075)) return true;
                            }
                        } else {
                            if ((codePoint >= 3146) && (codePoint <= 3149)) return true;
                        }
                    }
                }
            } else {
                if (codePoint <= 3396) {
                    if (codePoint >= 3390) return true;
                    if (codePoint <= 3270) {
                        if (codePoint >= 3270) return true;
                        if (codePoint <= 3260) {
                            if (codePoint >= 3260) return true;
                            if (codePoint <= 3203) {
                                if (codePoint >= 3202) return true;
                                if ((codePoint >= 3170) && (codePoint <= 3171)) return true;
                            }
                        } else {
                            if (codePoint <= 3268) {
                                if (codePoint >= 3265) return true;
                                if ((codePoint >= 3262) && (codePoint <= 3263)) return true;
                            }
                        }
                    } else {
                        if (codePoint <= 3299) {
                            if (codePoint >= 3298) return true;
                            if (codePoint <= 3286) {
                                if (codePoint >= 3285) return true;
                                if ((codePoint >= 3276) && (codePoint <= 3277)) return true;
                            }
                        } else {
                            if ((codePoint >= 3330) && (codePoint <= 3331)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 3459) {
                        if (codePoint >= 3458) return true;
                        if (codePoint <= 3415) {
                            if (codePoint >= 3415) return true;
                            if (codePoint <= 3405) {
                                if (codePoint >= 3405) return true;
                                if ((codePoint >= 3398) && (codePoint <= 3400)) return true;
                            }
                        } else {
                            if ((codePoint >= 3426) && (codePoint <= 3427)) return true;
                        }
                    } else {
                        if (codePoint <= 3542) {
                            if (codePoint >= 3542) return true;
                            if (codePoint <= 3540) {
                                if (codePoint >= 3535) return true;
                                if ((codePoint >= 3530) && (codePoint <= 3530)) return true;
                            }
                        } else {
                            if ((codePoint >= 3544) && (codePoint <= 3545)) return true;
                        }
                    }
                }
            }
        }
    } else {
        if (codePoint <= 6099) {
            if (codePoint >= 6070) return true;
            if (codePoint <= 3991) {
                if (codePoint >= 3988) return true;
                if (codePoint <= 3893) {
                    if (codePoint >= 3893) return true;
                    if (codePoint <= 3761) {
                        if (codePoint >= 3761) return true;
                        if (codePoint <= 3633) {
                            if (codePoint >= 3633) return true;
                            if (codePoint <= 3571) {
                                if (codePoint >= 3570) return true;
                                if ((codePoint >= 3551) && (codePoint <= 3551)) return true;
                            }
                        } else {
                            if (codePoint <= 3662) {
                                if (codePoint >= 3655) return true;
                                if ((codePoint >= 3636) && (codePoint <= 3642)) return true;
                            }
                        }
                    } else {
                        if (codePoint <= 3789) {
                            if (codePoint >= 3784) return true;
                            if (codePoint <= 3772) {
                                if (codePoint >= 3771) return true;
                                if ((codePoint >= 3764) && (codePoint <= 3769)) return true;
                            }
                        } else {
                            if ((codePoint >= 3864) && (codePoint <= 3865)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 3956) {
                        if (codePoint >= 3956) return true;
                        if (codePoint <= 3903) {
                            if (codePoint >= 3902) return true;
                            if (codePoint <= 3897) {
                                if (codePoint >= 3897) return true;
                                if ((codePoint >= 3895) && (codePoint <= 3895)) return true;
                            }
                        } else {
                            if ((codePoint >= 3953) && (codePoint <= 3954)) return true;
                        }
                    } else {
                        if (codePoint <= 3975) {
                            if (codePoint >= 3974) return true;
                            if (codePoint <= 3972) {
                                if (codePoint >= 3970) return true;
                                if ((codePoint >= 3962) && (codePoint <= 3968)) return true;
                            }
                        } else {
                            if ((codePoint >= 3984) && (codePoint <= 3986)) return true;
                        }
                    }
                }
            } else {
                if (codePoint <= 4196) {
                    if (codePoint >= 4194) return true;
                    if (codePoint <= 4028) {
                        if (codePoint >= 4026) return true;
                        if (codePoint <= 4006) {
                            if (codePoint >= 4003) return true;
                            if (codePoint <= 4001) {
                                if (codePoint >= 3998) return true;
                                if ((codePoint >= 3993) && (codePoint <= 3996)) return true;
                            }
                        } else {
                            if (codePoint <= 4024) {
                                if (codePoint >= 4013) return true;
                                if ((codePoint >= 4008) && (codePoint <= 4011)) return true;
                            }
                        }
                    } else {
                        if (codePoint <= 4185) {
                            if (codePoint >= 4182) return true;
                            if (codePoint <= 4158) {
                                if (codePoint >= 4139) return true;
                                if ((codePoint >= 4038) && (codePoint <= 4038)) return true;
                            }
                        } else {
                            if ((codePoint >= 4190) && (codePoint <= 4192)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 4959) {
                        if (codePoint >= 4959) return true;
                        if (codePoint <= 4237) {
                            if (codePoint >= 4226) return true;
                            if (codePoint <= 4212) {
                                if (codePoint >= 4209) return true;
                                if ((codePoint >= 4199) && (codePoint <= 4205)) return true;
                            }
                        } else {
                            if ((codePoint >= 4239) && (codePoint <= 4239)) return true;
                        }
                    } else {
                        if (codePoint <= 5971) {
                            if (codePoint >= 5970) return true;
                            if (codePoint <= 5940) {
                                if (codePoint >= 5938) return true;
                                if ((codePoint >= 5906) && (codePoint <= 5908)) return true;
                            }
                        } else {
                            if ((codePoint >= 6002) && (codePoint <= 6003)) return true;
                        }
                    }
                }
            }
        } else {
            if (codePoint <= 8432) {
                if (codePoint >= 8400) return true;
                if (codePoint <= 6972) {
                    if (codePoint >= 6972) return true;
                    if (codePoint <= 6592) {
                        if (codePoint >= 6576) return true;
                        if (codePoint <= 6313) {
                            if (codePoint >= 6313) return true;
                            if (codePoint <= 6157) {
                                if (codePoint >= 6155) return true;
                                if ((codePoint >= 6109) && (codePoint <= 6109)) return true;
                            }
                        } else {
                            if (codePoint <= 6459) {
                                if (codePoint >= 6448) return true;
                                if ((codePoint >= 6432) && (codePoint <= 6443)) return true;
                            }
                        }
                    } else {
                        if (codePoint <= 6916) {
                            if (codePoint >= 6912) return true;
                            if (codePoint <= 6683) {
                                if (codePoint >= 6679) return true;
                                if ((codePoint >= 6600) && (codePoint <= 6601)) return true;
                            }
                        } else {
                            if ((codePoint >= 6964) && (codePoint <= 6970)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 7042) {
                        if (codePoint >= 7040) return true;
                        if (codePoint <= 6980) {
                            if (codePoint >= 6980) return true;
                            if (codePoint <= 6978) {
                                if (codePoint >= 6978) return true;
                                if ((codePoint >= 6974) && (codePoint <= 6975)) return true;
                            }
                        } else {
                            if ((codePoint >= 7019) && (codePoint <= 7027)) return true;
                        }
                    } else {
                        if (codePoint <= 7654) {
                            if (codePoint >= 7616) return true;
                            if (codePoint <= 7223) {
                                if (codePoint >= 7204) return true;
                                if ((codePoint >= 7073) && (codePoint <= 7082)) return true;
                            }
                        } else {
                            if ((codePoint >= 7678) && (codePoint <= 7679)) return true;
                        }
                    }
                }
            } else {
                if (codePoint <= 43137) {
                    if (codePoint >= 43136) return true;
                    if (codePoint <= 42621) {
                        if (codePoint >= 42620) return true;
                        if (codePoint <= 12442) {
                            if (codePoint >= 12441) return true;
                            if (codePoint <= 12335) {
                                if (codePoint >= 12330) return true;
                                if ((codePoint >= 11744) && (codePoint <= 11775)) return true;
                            }
                        } else {
                            if ((codePoint >= 42607) && (codePoint <= 42610)) return true;
                        }
                    } else {
                        if (codePoint <= 43019) {
                            if (codePoint >= 43019) return true;
                            if (codePoint <= 43014) {
                                if (codePoint >= 43014) return true;
                                if ((codePoint >= 43010) && (codePoint <= 43010)) return true;
                            }
                        } else {
                            if ((codePoint >= 43043) && (codePoint <= 43047)) return true;
                        }
                    }
                } else {
                    if (codePoint <= 43587) {
                        if (codePoint >= 43587) return true;
                        if (codePoint <= 43347) {
                            if (codePoint >= 43335) return true;
                            if (codePoint <= 43309) {
                                if (codePoint >= 43302) return true;
                                if ((codePoint >= 43188) && (codePoint <= 43204)) return true;
                            }
                        } else {
                            if ((codePoint >= 43561) && (codePoint <= 43574)) return true;
                        }
                    } else {
                        if (codePoint <= 65039) {
                            if (codePoint >= 65024) return true;
                            if (codePoint <= 64286) {
                                if (codePoint >= 64286) return true;
                                if ((codePoint >= 43596) && (codePoint <= 43597)) return true;
                            }
                        } else {
                            if ((codePoint >= 65056) && (codePoint <= 65062)) return true;
                        }
                    }
                }
            }
        }
    }
    return false;
};
ERMSRESTAutoSuggest.prototype.isWordBreak = function (codePoint) {
    if (codePoint <= 61) {
        if (codePoint >= 61) return true;
        if (codePoint <= 47) {
            if (codePoint >= 45) return true;
            if (codePoint <= 39) {
                if (codePoint >= 39) return true;
                if ((codePoint >= 32) && (codePoint <= 32)) return true;
            }
        } else {
            if ((codePoint >= 58) && (codePoint <= 58)) return true;
        }
    } else {
        if (codePoint <= 92) {
            if (codePoint >= 92) return true;
            if ((codePoint >= 64) && (codePoint <= 64)) return true;
        } else {
            if ((codePoint >= 95) && (codePoint <= 95)) return true;
        }
    }
    return false;
};
ERMSRESTAutoSuggest.prototype.makeListItem = function (contentDocument, prefix, suggestion) {
    var li = contentDocument.createElement("li");
    var prefixLength = prefix.length;
    var prefixOffset = 0;
    var suggestionLength = suggestion.length;
    var suggestionOffset = 0;
    var fallback = 0;
    var start = 0;
    li.style.cursor = "pointer";
    while (suggestionOffset < suggestionLength) {
        var suggestionCodePoint = suggestion.charCodeAt(suggestionOffset++);
        if (this.isAccent(suggestionCodePoint)) continue;
        if (44 == suggestionCodePoint) continue;
        if (this.isWordBreak(suggestionCodePoint)) {
            fallback = suggestionOffset;
            suggestionCodePoint = 32;
        }
        var prefixCodePoint = prefix.charCodeAt(prefixOffset++);
        if (suggestionCodePoint == prefixCodePoint) {
            if (prefixOffset == prefixLength) {
                var span = contentDocument.createElement("span");
                span.appendChild(contentDocument.createTextNode(suggestion.substr(start, suggestionOffset - start)));
                li.appendChild(span);
                if (32 != suggestionCodePoint) {
                    start = suggestionOffset;
                    while (suggestionOffset < suggestionLength) {
                        suggestionCodePoint = suggestion.charCodeAt(suggestionOffset++);
                        if (this.isWordBreak(suggestionCodePoint)) {
                            fallback = suggestionOffset;
                            suggestionCodePoint = 32;
                            break;
                        }
                    }
                    li.appendChild(contentDocument.createTextNode(suggestion.substr(start, suggestionOffset - start)));
                }
                start = suggestionOffset;
                fallback = suggestionOffset;
                prefixOffset = 0;
            }
        } else {
            if (fallback > start) {
                li.appendChild(contentDocument.createTextNode(suggestion.substr(start, fallback - start)));
                start = fallback;
                prefixOffset = 0;
            } else {
                while (suggestionOffset < suggestionLength) {
                    suggestionCodePoint = suggestion.charCodeAt(suggestionOffset++);
                    if (this.isWordBreak(suggestionCodePoint)) {
                        fallback = suggestionOffset;
                        suggestionCodePoint = 32;
                        break;
                    }
                }
                li.appendChild(contentDocument.createTextNode(suggestion.substr(start, suggestionOffset - start)));
                start = suggestionOffset;
                fallback = suggestionOffset;
                prefixOffset = 0;
            }
        }
    }
    li.appendChild(contentDocument.createTextNode(suggestion.substr(start, suggestionOffset - start)));
    return li;
};
ERMSRESTAutoSuggest.prototype.setCookie = function (value) {
    document.cookie = "AutoSuggest=" + value.toString() + ";path=/";
};
ERMSRESTAutoSuggest.prototype.updatePrefix = function () {
    if ((null == this._path) || ("" == this._showSuggestions.value) || !this._enabled) return false;
    this._dirty = true;
    var _this = this;
    this._timerID = setTimeout(function () {
        _this.handleTimeout();
    }, this._delay);
    return true;
};
