



function f200() {
var acdb = [];
var inputs = document.getElementsByTagName('input');
for (i = 0; input = inputs[i]; i++) {
if (input && f201(input, 'autocomplete')) {
uri = input.value;
if (!acdb[uri]) {
acdb[uri] = new ACDB(uri, input.getAttribute('function'));
}
id = input.id.substr(0, input.id.length - 13);
input = document.getElementById(id);
input.setAttribute('autocomplete', 'OFF');
input.form.onsubmit = autocompleteSubmit;   // RB 14.9.2007
new jsAC(input, acdb[uri]);

}
}
};




function autocompleteSubmit() {
var popup = document.getElementById('autocomplete');
if (popup) {
popup.owner.hidePopup();
popup.wasSubmitted = true;
return false;
}
return true;
};





function jsAC(input, db) {
var ac = this;
this.input = input;
this.db = db;
this.input.onkeydown = function (event) { return ac.onkeydown(this, event); };
this.input.onkeyup = function (event) { ac.onkeyup(this, event) };
this.input.onblur = function () { ac.hidePopup() };
this.popup = document.createElement('div');
this.popup.id = 'autocomplete';
this.popup.owner = this;
};




jsAC.prototype.hidePopup = function (keycode) {
if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) {
this.input.value = this.selected.autocompleteValue;

}
if (this.popup.parentNode && this.popup.parentNode.tagName) {
f43(this.popup);
}
this.selected = false;
};





jsAC.prototype.onkeydown = function (input, e) {
if (!e) {
e = window.event;
}
switch (e.keyCode) {
case 40: // down arrow
this.selectDown();
return false;
case 38: // up arrow
this.selectUp();
return false;
default: // all other keys
return true;
}
};




jsAC.prototype.onkeyup = function (input, e) {
if (!e) {
e = window.event;
}
switch (e.keyCode) {
case 16: // shift
case 17: // ctrl
case 18: // alt
case 20: // caps lock
case 33: // page up
case 34: // page down
case 35: // end
case 36: // home
case 37: // left arrow
case 38: // up arrow
case 39: // right arrow
case 40: // down arrow
return true;

case 9:  // tab
case 13: // enter
case 27: // esc

this.hidePopup(e.keyCode);
return true;

default: // all other keys
if (input.value.length > 0)
this.populatePopup();
else
this.hidePopup(e.keyCode);
return true;
}
};




jsAC.prototype.select = function (node) {
this.input.value = node.autocompleteValue;
};




jsAC.prototype.selectDown = function () {
if (this.selected && this.selected.nextSibling) {
this.highlight(this.selected.nextSibling);
}
else {
var lis = this.popup.getElementsByTagName('li');
if (lis.length > 0) {
this.highlight(lis[0]);
}
}
};




jsAC.prototype.selectUp = function () {
if (this.selected && this.selected.previousSibling) {
this.highlight(this.selected.previousSibling);
}
};




jsAC.prototype.highlight = function (node) {
f202(this.selected, 'selected');
f203(node, 'selected');
this.selected = node;
};




jsAC.prototype.unhighlight = function (node) {
f202(node, 'selected');
this.selected = false;
};




jsAC.prototype.populatePopup = function () {
var ac = this;
var pos = f4(this.input);
this.selected = false;
this.popup.style.top   = (pos.y + this.input.offsetHeight) +'px';
this.popup.style.left  = pos.x +'px';
this.popup.style.width = (this.input.offsetWidth - 4) +'px';
this.db.owner = this;
this.db.search(this.input.value);
};




jsAC.prototype.found = function (matches) {

if (this.popup.wasSubmitted) {
this.popup.wasSubmitted = false;
return;
}
while (this.popup.hasChildNodes()) {
this.popup.removeChild(this.popup.childNodes[0]);
}
if (!this.popup.parentNode || !this.popup.parentNode.tagName) {
document.getElementsByTagName('body')[0].appendChild(this.popup);
}
var ul = document.createElement('ul');
var ac = this;
if (matches.length > 0) {
for (i=0; i < matches.length; i++) {
li = document.createElement('li');
div = document.createElement('div');
div.innerHTML = matches[i][1];
li.appendChild(div);
li.autocompleteValue = matches[i][0];
li.onmousedown = function() { ac.select(this); };
li.onmouseover = function() { ac.highlight(this); };
li.onmouseout  = function() { ac.unhighlight(this); };
ul.appendChild(li);
}
this.popup.appendChild(ul);
}
else {
this.hidePopup();
}
f202(this.input, 'throbbing');
};




function ACDB(uri) {
this.uri = uri;
this.delay = 100;
this.cache = {};
};




ACDB.prototype.search = function(searchString) {
this.searchString = searchString;
if (this.cache[searchString]) {
return this.owner.found(this.cache[searchString]);
}
if (this.timer) {
clearTimeout(this.timer);
}
var db = this;
this.timer = setTimeout(function() {
f203(db.owner.input, 'throbbing');
var uri = db.uri.replace('$', encodeURIComponent(searchString));
f204(uri, db.receive, db);
}, this.delay);
};




ACDB.prototype.receive = function(string, xmlhttp, acdb) {
if (xmlhttp.status != 200) {
f202(acdb.owner.input, 'throbbing');

}
if (string.indexOf('|') == -1) {
string = ''
}

var matches = new Array();
var values = string.length > 0 ? string.split('\n') : [];
for (var i=0; i < values.length; i++) {
var tmp = f148(values[i]).split('|');
matches[i] = new Array(tmp[1], tmp[1]);     // Display and select values
}

acdb.cache[acdb.searchString] = matches;
acdb.owner.found(matches);
this.searchString = '';
};





function f204(v9, v205, v206) {
v9 = "http://" + v207 + v9;
var v1 = new XMLHttpRequest();
var v19 = true;
if (!v205)
v19 = false;
v1.open('GET', v9, v19);
v1.send(null);

if (v19) {
if (v205) {
v1.onreadystatechange = function() {
if (v1.readyState == 4) {
v205(v1.responseText, v1, v206)
}
}
}
return true;
}
else {

return v1.responseText;
}
};




function f201(v44, v208) {
if (v44.className == v208) {
return true;
}
var v38 = new RegExp('(^| )'+ v208 +'($| )')
if (v38.test(v44.className)) {
return true;
}
return false;
};




function f203(v44, v208) {
if (f201(v44, v208)) {
return false;
}
v44.className += ' '+ v208;
return true;
};




function f202(v44, v208) {
if (!f201(v44, v208)) {
return false;
}
v44.className = f209('(^| )'+ v208 +'($| )', '', v44.className);
return true;
};




function f209(v210, v211, v212) {
return v212.replace(new RegExp(v210,'g'), v211);
};
