if (typeof(changeVals)=='undefined') {
function changeVals(id,val) {
var e1 = document.getElementById(id);
if (e1==null) return false;
switch (e1.tagName) {
case 'SELECT' 	:	for (i=0;i<e1.options.length;i++)
if (e1.options[i].value==val)
e1.selectedIndex = i;
break;
case 'INPUT'	: 	switch (e1.type) {
case 'checkbox' : if (e1.value==val)
e1.checked = true;
break;
default :	e1.value = val;
break;
}
break;
default : break;
}
return;
}
}
function suchbox() {
this.form = false;
this.formname = false;
this.content = false;
this.content_id = false;
this.fields = new Array();
this.sfields = new Array();
this.start_sb = true;
this.sf = false;

this.init_suchbox 	= _init_suchbox;
this.reset_fields 	= _reset_fields;
this.add_field 		= _add_field;
this.set_field 		= _set_field;
this.show			= _show;
this.getdata		= _getdata;
this.ref			= _ref;
this.opencontent	= _opencontent;
this.show_sfield	= _show_sfield;
}

function _init_suchbox(id,cont_id) {
var e1 = document.getElementById(id);

if (e1!=null) {
this.form = e1;
this.formname = id;
}
for(i=0;i<document.forms[this.formname].elements.length;i++) {
document.forms[this.formname].elements[i].onchange = new Function('webkfz.ref();');
}
var e2 = document.getElementById(cont_id);
if (e2!=null) {
this.content = e2;
this.content_id = cont_id;
}
webkfz.getdata();
}

function _reset_fields() {
this.fields.length = 0;
this.sfields.length = 0;
for(i=0;i<document.forms[this.formname].elements.length;i++) {
	if (document.forms[this.formname].elements[i].name.search(/von/)==-1 &&
		document.forms[this.formname].elements[i].name.search(/bis/)==-1)
document.forms[this.formname].elements[i].options.length=0;
}
}

function _add_field(id,val) {
this.fields[this.fields.length] = {'id' : id, 'val' : val };
}

function _set_field(id,val) {
this.sfields[this.sfields.length] = {'id' : id, 'val' : val };
}

function _show_sfield() {
for (vi=0;vi<this.sfields.length;vi++) {
f1 = this.sfields[vi];
changeVals(f1.id,f1.val);
}
}

function _show() {
var f1 = null;
var last = null;
for (i=0;i<this.fields.length;i++) {
f1 = this.fields[i];
if (f1.id == 'wk_treffer') {
var e2 = document.getElementById(f1.id);
if (e2!=null)
e2.innerHTML = f1.val;
} else {
if (last!=f1.id) {
var e1 = document.getElementById(f1.id);
if (e1!=null && e1.options.length==0)
e1.options[e1.options.length] = new Option('Bitte wählen', '', false, false);
last = f1.id;
}
if (e1!=null)
e1.options[e1.options.length] = new Option(f1.val, f1.val, false, false);
}
}
this.show_sfield();
}

function _getdata() {
var params = Object();
for(i=0;i<document.forms[this.formname].elements.length;i++) {
params[document.forms[this.formname].elements[i].name] =
	document.forms[this.formname].elements[i].value;
}
this.formdata = params;
params['wk_mode'] = 'list';

if (this.start_sb==true)
params['wk_first'] = '1';
new Ajax.Request('/ajax.php', {
method: 'post',
parameters: params,
onSuccess: function(request) {
try {
webkfz.reset_fields();
//window.alert(request.responseText);
eval(String(request.responseText));
//window.alert(request.responseText);
if (webkfz.start_sb==true) {
start_sb();
webkfz.show();
webkfz.start_sb = false;
} else {
webkfz.show();
if (webkfz.content!=null && webkfz.content!=false)
webkfz.opencontent();
}
} catch (e) {

}
}
});
}

function _opencontent() {
var params = Form.serialize(this.formname,true);
this.formdata = params;
params['wk_mode'] = 'listdata';
new Ajax.Request('/ajax.php', {
method: 'post',
parameters: params,
onSuccess: function(request) {
try {
webkfz.content.innerHTML = String(request.responseText);
} catch (e) {

}
}
});
}

function _ref() {
this.getdata();
}
