// ajax.js - adaptiert durch Tim Reeves aus Internet-Pro 11/05,
// ursprunglich programmiert von Marco Zierl.
// Fassung für Hauser Frankfurt, Stand: 2009-10-02

// THE BASIS OF ALL AJAX

var ajaxok = false;
var prefix = '../';		// Relative path prefix to server scripts
// 2006-08-25 Prefix is now always '../', since all Webpages are by design "one dir down"
var xmlhttp = null;
var target_select_obj = null;

function getXMLHttpRequest() {
	// mochiKit does it more or less so...
    var tryThese = [
        function () { return new XMLHttpRequest(); },
        function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
        function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
        function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
    ];
    for (var i = 0; i < tryThese.length; i++) {
        var func = tryThese[i];
        try {
            return func();
        } catch (e) {
            // pass
        }
    }
    return null;
}

function getFirefox() {
	var getFF = "Am Besten holen Sie den modernen Gratis-Browser \"Firefox\" \nper DownLoad. Wollen Sie jetzt Firefox herunterladen?"
	var ans = confirm(getFF);
	if (ans == true) location.href = 'http://www.mozilla-europe.org/de/products/firefox/';
	return;
}

// EVERY page calls either ajaxProbe() or ajaxOnload()
// so both of these set the general server path prefix
// 2006-08-25 Prefix is now always '../', since all Webpages are by design "one dir down"
function setPrefix() {
	// The url is something like...
	// http://localhost/hauser7/allgemein/philosphie.html
	// http://localhost/hauser7/leiter/Heinrich_Gruber.html
	// http://www.grafik-fischer.de/hauser3/allgemein/philosphie.html
	// http://www.hauser-exkursionen.de/allgemein/philosphie.html
	// var url = document.URL;
	// IF it starts like "http://.../" then delete that
	// var r1 = url.replace(/http:\/\/.+?\/(.)/, "$1");
	// IF "hauser{.*}/" follows, then delete that too
	// var r2 = r1.replace(/hauser.*?\/(.)/, "$1");
	// IF there is yet another slash, then it's a subdir, prefix='../'
	// if (r2.search(/\/./) != -1) prefix = '../';

	var agent=navigator.userAgent;
	if (agent.indexOf('Mac') != -1 && agent.indexOf('MSIE 5') != -1){
		// MSIE on Mac is a catastrophy - not supported
		alert("Sie verwenden den MSIE 5 - Mac Browser, mit\ndem diese Website nicht korrekt dargestellt wird.");
		getFirefox();
	}
	if (!document.getElementById){
		alert("Sie verwenden ein sehr veralteter Browser, mit\ndem diese Website nicht korrekt dargestellt wird.");
		getFirefox();
	}

	return;
}

// Standard functions to delete a subtree in DOM model
function delKids(prnt)
{
	// alert('delKids: ' + prnt.nodeName + ' / ' + prnt.nodeValue);
	var c = prnt.lastChild, p;
	while (c) {
		// Note previous while last is still there!
		p = c.previousSibling;
		delTree(prnt, c);
		c = p;
	}
	return;
}

function delTree(prnt, chld)
{
	// alert('delTree:: Parent: ' + prnt.nodeName + ' / ' + prnt.nodeValue +
	// 	  ' Child: ' + chld.nodeName + ' / ' + chld.nodeValue);
	var c = chld.lastChild, p;
	while (c) {
		p = c.previousSibling;
		delTree(chld, c);
		c = p;
	}
	prnt.removeChild(chld);
	return;
}

function debugToPfad(txt) {
	var jetzt = new Date();
	var debugTxt = jetzt.getTime() + ' ' + txt;
	var pfad = document.getElementById('pfad'); delKids(pfad);
	var textObj = document.createTextNode(debugTxt);
	pfad.appendChild(textObj);
	return;
}

function ctrImage() {
	// The hidden counter which gathers statistics
	// Insert the URL call as the source of an image which is added via DOM
	// alert('Counter-Call');
	var ref = '';
	if (document.images && document.referrer && document.referrer.length>0)
	 { ref += escape(document.referrer); }
	var fbt = '..', cookies = ' U';
	if (screen.colorDepth && screen.colorDepth != null) {
		fbt = screen.colorDepth;
		if (fbt.length == 1) { fbt = '0' + screen.colorDepth; }
		}
	if (typeof navigator.cookieEnabled == 'boolean')
		cookies = navigator.cookieEnabled ? ' J' : ' N';
	ref += '&sh='+screen.height+'&sw='+screen.width+'&user='+fbt+cookies;
	var ctrImg = document.createElement('img');
	ctrImg.width = 1;
	ctrImg.height = 1;
	ctrImg.src = '/cgi-bin/counter.pl?id=1&rl=1800&ref=' + ref;
	// ctrImg.src = '/cgi-bin/counter.pl?id=1&rl=0&ref=' + ref;
	var ctrDiv = document.getElementById('ctrDiv');
	ctrDiv.appendChild(ctrImg);
	return;
}

function initPage() {
	// Set the window name to allow us to know if this is the inital website entry
	var re = /^Hauser_exkursionen_Frankfurt_de/;
	if (! re.test(window.name)) {
		// It IS the initial website entry - set the window name
		window.name = 'Hauser_exkursionen_Frankfurt_de';
		// And call the counter
		ctrImage();
	}
	// Caveat: Since hardly any site sets the window name, it tends to stay this way
	//         meaning that subsequent visits - even hours later - are not noted
	// The alternative is to have the counter called by EVERY page and the data is
	// not recorded by the counter software if the IP address is (time-)locked out.
	// NOTE that the window name is tab-specific in browsers with tabs
	return;
}

// Perform a test for AJAX capability on page loading
// Called by dynamic pages which don't require AJAX-setting of
// Team-Name / Touren-Ampel / E-Mail-Adresse

// Those which do call ajaxOnload() (for the above reasons)
// get an unneccessary Ajax-Update of Volltext- und Tourensuche
// Probe:  vtsuche.php, leitersuche.php, toursuche.php
// Onload: teamsuche.php (wg. Mitarbeiter-Emails)

function ajaxProbe() {
	setPrefix();
	xmlhttp = getXMLHttpRequest();
	if (xmlhttp)
		ajaxok = true;
	else
		alert("AJAX-Technologie nicht verfügbar");
	// Set window name and call the counter if inital website entry
	initPage();
	return;
}

// THE FUNCTIONS FOR UPDATING THE LAND LIST ON CONTINENT CHANGE

// Add a single option element to a select list
function add_option(obj, optext, optval, selval)
{
	// alert("add_element: " + optext);
	var newOption = new Option(optext, optval);
	var idx = obj.options.length;
	obj.options[idx] = newOption;
	obj.options[idx].selected = (optval == selval);
	return;
}

// Insert the number of tours which match the field values
function set_anztouren(anz)
{
	var anztext = anz == ' ' ? ' ' : ' ' + anz + ' ';
	var agent=navigator.userAgent.toLowerCase();
	if (agent.indexOf('safari') != -1) {
		// Safari ALWAYS displays a button - nutze die Button-Beschriftung
		optval = '»' + anztext + 'Touren zeigen';
		document.getElementById('banztouren').value = optval;
		}
	else
		document.getElementById('sanztouren').firstChild.nodeValue = anztext;
	return;
}

// Rebuild a complete list of select box options
// Called when continent changes for new list of lands
function optionData()
{
	var xmlDocument = xmlhttp.responseXML;
	var optval='', optext='', base=null, i=0;

	// Remove all old options from the list
	// showProps(target_select_obj.options);
	while (target_select_obj.options.length > 0) {
		if (target_select_obj.remove)
			target_select_obj.remove(0);
		else
			target_select_obj.options.remove(0);
	}
	// Add new options to list
	for (i=0; i< xmlDocument.getElementsByTagName("llopt").length; i++)
	{
		base = xmlDocument.getElementsByTagName("llopt")[i];
		optval = base.getElementsByTagName("optval")[0].childNodes[0].nodeValue;
		optext = base.getElementsByTagName("optext")[0].childNodes[0].nodeValue;
		// No option will be selected, display defaults to the first
		add_option(target_select_obj, optext, optval, '');
	}
	// Enable the listbox again if it has more than one option
	if (i>1) target_select_obj.disabled = false;

	// ANZAHL TOUREN
	if (xmlDocument.getElementsByTagName("anztouren")[0])
	   set_anztouren(xmlDocument.getElementsByTagName("anztouren")[0].childNodes[0].nodeValue);

	// Remove any old message
	if (document.getElementById('toursuchemsg')) {
		var chld = document.getElementById('toursuchemsg');
		var prnt = chld.parentNode;
		delTree(prnt,chld);
		// IE positioning bug - button slips down, although posn "bottom"
		document.getElementById('panztouren').className = 'panztouren';
		document.getElementById('danztouren').className = 'danztouren';
		}

	return;
}

function optionsHttpState()
{
	if (xmlhttp.readyState == 4)
	{
		if ( xmlhttp.status == 200) {
			// daten erfolgreich geladen: starte Verarbeitung
			optionData();
		} else {
			alert("Fehler beim Abrufen der Option-XML Daten - Status " + xmlhttp.status);
			alert("Statusmeldung vom Server: " + xmlhttp.statusText);
			alert("Debug: Url=" + document.URL + " Prefix=" + prefix);
		}
	}
	return;
}

function get_select_data(select_name, url, selected_id)
{
	// select_name = name of target dropdown to get new option list
	// url         = url to call which should deliver the new option data
	// selected_id = name of dropdown calling this function - delivers index
	// UND ZWAR: get_select_data('f_land','get_options.php?typ=laender','f_ziel');

	// var debugTxt = "get_select_data: " + select_name + " / " + url + " / " + selected_id;
	// debugToPfad(debugTxt);

	// Do nothing if AJAX technology not available
	if (!ajaxok) return;

	if (select_name != "") {
		target_select_obj = eval("document.forms['toursuche']." + select_name);
		// Disable the target dropdown
		target_select_obj.disabled = true;
	}
	else
		target_select_obj = null;

	if (selected_id != ""){
		url += "&sel=" + eval("document.forms['toursuche']." + selected_id + ".value");
	}
	// Get the new option list via AJAX
	if (xmlhttp) {
		// xmlhttp.open("GET", prefix + "cgi-bin/" + url, true );	// Fails at Strato
		// xmlhttp.open("GET", "asien.xml", true ); 		// Works at Strato
		// 3rd parameter is true for asynchronous, false for synchronous
		xmlhttp.open("GET", prefix + 'scripts/' + url, true);
		// alert("XMLHttpObject geöffnet");
		xmlhttp.onreadystatechange = optionsHttpState;
		xmlhttp.send(null);
		}
	else {
		alert("XMLHttpObject fehlt!");
	}
	return;
}

// THE FUNCTIONS TO POPULATE THE FORM FIELDS AND ICONS ON PAGE LOADING

function onloadData()
{
	var xmlDocument = xmlhttp.responseXML;
	var optval='', optext='', welches='', i=0, obj=null;

	// Empty text values mean there is no child node - catch them
	// alert(xmlhttp.responseText);

	// DIE VOLLTEXT-SUCHE
	if (xmlDocument.getElementsByTagName("vtsuche")[0] &&
		xmlDocument.getElementsByTagName("vtsuche")[0].childNodes[0] &&
		document.forms['vtsuche'].f_vtsuche)
		document.forms['vtsuche'].f_vtsuche.value =
			xmlDocument.getElementsByTagName("vtsuche")[0].childNodes[0].nodeValue;

	// AKTUELLER KONTINENT
	obj = document.forms['toursuche'].f_ziel;
	welches = xmlDocument.getElementsByTagName("ziel")[0].childNodes[0].nodeValue;
	for (i=0; i< obj.options.length; i++)
	{
		if (obj.options[i].value == welches) {
			obj.options[i].selected = true;
			break;
			}
	}

	// DIE LÄNDERLISTE
	var land_list_obj = document.forms['toursuche'].f_land;
	welches = xmlDocument.getElementsByTagName("land")[0].childNodes[0].nodeValue;
	// Remove all old options from the list
	// showProps(target_select_obj.options);
	while (land_list_obj.options.length > 0) {
		if (land_list_obj.remove)
			land_list_obj.remove(0);
		else
			land_list_obj.options.remove(0);
	}
	// Add new options to the list
	for (i=0; i< xmlDocument.getElementsByTagName("llopt").length; i++)
	{
		obj = xmlDocument.getElementsByTagName("llopt")[i];
		optval = obj.getElementsByTagName("optval")[0].childNodes[0].nodeValue;
		optext = obj.getElementsByTagName("optext")[0].childNodes[0].nodeValue;
		add_option(land_list_obj, optext, optval, welches);
	}
	// Enable the listbox if it has more than one option
	if (i>1) land_list_obj.disabled = false;

	// MAX. PREIS
	if (xmlDocument.getElementsByTagName("maxpreis")[0])
		document.forms['toursuche'].f_maxpreis.value =
			xmlDocument.getElementsByTagName("maxpreis")[0].childNodes[0].nodeValue;

	// SCHWIERIGKEITSGRAD
	obj = document.forms['toursuche'].f_schwierig;
	welches = xmlDocument.getElementsByTagName("schwierig")[0].childNodes[0].nodeValue;
	for (i=0; i< obj.options.length; i++)
	{
		if (obj.options[i].value == welches) {
			obj.options[i].selected = true;
			break;
			}
	}

	// FRÜHESTER ABREISE
	if (xmlDocument.getElementsByTagName("abdatum")[0])
		document.forms['toursuche'].f_abdatum.value =
			xmlDocument.getElementsByTagName("abdatum")[0].childNodes[0].nodeValue;

	// SPÄTESTER RÜCKREISE
	if (xmlDocument.getElementsByTagName("rueckdatum")[0])
		document.forms['toursuche'].f_rueckdatum.value =
			xmlDocument.getElementsByTagName("rueckdatum")[0].childNodes[0].nodeValue;

	// ANZAHL TOUREN
	if (xmlDocument.getElementsByTagName("anztouren")[0] &&
		xmlDocument.getElementsByTagName("anztouren")[0].childNodes[0])
	   set_anztouren(xmlDocument.getElementsByTagName("anztouren")[0].childNodes[0].nodeValue);

	// ALLE BUCHBARKEITSICONS EINSETZEN
	var rsnr = '', bbar = '', icon = '', text = '', idx, obj;
	var anz = xmlDocument.getElementsByTagName("reise").length;
	// alert(anz + ' Touren gefunden auf der Seite');
	for (i=0; i<anz; i++)
	{
		rsnr = xmlDocument.getElementsByTagName("reise")[i].childNodes[0].firstChild.data;
		bbar = xmlDocument.getElementsByTagName("reise")[i].childNodes[1].firstChild.data;
		icon = xmlDocument.getElementsByTagName("reise")[i].childNodes[2].firstChild.data;
		text = xmlDocument.getElementsByTagName("reise")[i].childNodes[3].firstChild.data;
		// alert(rsnr + ': ' + bbar + '/' + icon + '/' + text);
		obj = document.getElementById('ampel' + (i+1));
		obj.src = prefix + 'images/' + icon;
		obj.alt = text;
		obj.title = text;
		// Nicht-buchbare Touren dürfen keinen "Buchen" Verweis haben
		// - entfernen falls da
		if (bbar == 'N' && obj.nextSibling) {
			var chld = obj.nextSibling;
			var prnt = obj.parentNode;
			delTree(prnt,chld);
			}
	}

	// ETWAIGE EMAIL-ADRESSEN EINSETZEN
	var nr = '', link='', title='', subject='', href='';
	var textObj=null, linkObj=null, spanObj=null;
	var anz = xmlDocument.getElementsByTagName("email").length;
	for (var i=0; i<anz; i++)
	{
		// Hier zählt 'i' lediglich durch die Antworten, doch
		// <nr> bezieht sich korrekterweise auf die Anfrage!!
		nr = xmlDocument.getElementsByTagName("email")[i].childNodes[0].firstChild.data;
		// childNodes[1] = ID => not needed (but good for debugging :)
		link = xmlDocument.getElementsByTagName("email")[i].childNodes[2].firstChild.data;
		show = xmlDocument.getElementsByTagName("email")[i].childNodes[3].firstChild.data;
		title = xmlDocument.getElementsByTagName("email")[i].childNodes[4].firstChild.data;
		subject = xmlDocument.getElementsByTagName("email")[i].childNodes[5].firstChild.data;
		href = subject == '' ? 'mailto:' + link
							 : 'mailto:' + link + '?subject=' + subject;
		// alert(link);
		// Zunächst den Link vorbereiten
		textObj = document.createTextNode(show);
		linkObj = document.createElement('a');
		linkObj.setAttribute('href',href);
		linkObj.setAttribute('title',title);
		// Nun Grafik aushängen und Link einhängen
		spanObj = document.getElementById('email' + nr);
		delKids(spanObj);
		spanObj.appendChild(linkObj);
		// MSIE mag es nicht wenn der Textknoten vor dem Einhängen angehängt wird
		spanObj.childNodes[0].appendChild(textObj);
	}

	return;
}

function onloadHttpState()
{
	if (xmlhttp.readyState == 4)
	{
		if ( xmlhttp.status == 200) {
			// daten erfolgreich geladen: starte Verarbeitung
			onloadData();
		} else {
			alert("Fehler beim Abrufen der Onload-XML Daten - Status " + xmlhttp.status);
			alert("Statusmeldung vom Server: " + xmlhttp.statusText);
		}
	}
	return;
}

// This is called by all "static" pages i.e. *.html as <body onload> event
function ajaxOnload() {
	setPrefix();
	// Opera calculates the width of select boxes via w3c box model
	if (window.opera) {
		document.getElementById('f_ziel').className = 'schnell std';
		document.getElementById('f_land').className = 'schnell std';
		document.getElementById('f_maxpreis').className = 'schnell std serif';
		document.getElementById('f_schwierig').className = 'schnell std serif';
		if (document.getElementById('f_landname')) {
			document.getElementById('f_landname').style.height = '12px';
			}
		if (document.getElementById('f_landname2')) {
			document.getElementById('f_landname2').style.height = '12px';
			document.getElementById('f_landname').style.top = '0px';
			document.getElementById('f_landname2').style.top = '0px';
			}
	}
	// Perform a test for AJAX on page loading
	xmlhttp = getXMLHttpRequest();
	if (xmlhttp)
		ajaxok = true;
	else {
		alert("AJAX-Technologie nicht verfügbar");
		return;
		}
	var touren = '', emails = '', curid = '', sep='?', i;
	// Get a list of all the Tour Numbers on the page
	// They are the text content of cells with id's like "tournr<n>"
	for (i=1; true; i++) {
		curid = 'tournr' + i;
		if (document.getElementById(curid) &&
			document.getElementById('ampel' + i)) {
			touren += sep + curid + '=' +
					  document.getElementById(curid).firstChild.nodeValue;
			sep = '&';
			}
		else break;
	}
	// Get a list of all the Email Numbers on the page
	// They are the content of span-elements with id's like "email<n>"
	for (i=1; true; i++) {
		curid = 'email' + i;
		if (document.getElementById(curid)) {
			emails += sep + curid + '=' +
					  document.getElementById(curid).firstChild.id;
			sep = '&';
			}
		else break;
	}
	// Call "onload.php" on the server to return the current values
	// and insert these values into the displayed page
	var url = prefix + 'scripts/onload.php' + touren + emails;
	// alert(url);
	// debugToPfad(url);
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = onloadHttpState;
	xmlhttp.send(null);
	// Set window name and call the counter if initial website entry
	initPage();
	return;
}

// THE FUNCTIONS TO UPDATE SERVER SESSION VARS ON SINGLE FIELD CHANGE

/*  Whenever the user changes a field value (in either form) then the
	new value is sent to the server and put in the session variables -
	which involves getting at least a small return document from the server.
	However, when the form is submitted this action is not required - in fact,
	a document would be returned to a page which no longer exists, so we want
	to suppress the onChange action when the event which triggers the onChange
	is the form submission. This in turn is caused by EITHER
	- the user is in a text input field and hits ENTER, or
	- he or she clicks on the submit button.
	In both cases the onChange happens BEFORE the onSubmit, so we have to
	add a small delay to the onChange action, and then not do it if we find
	we are at that time submitting the form.
	Note that onChange is triggered by onMouseDown on the submit button -
	it'll come up again and be a click soon enough! If we would wait for the
	onClick event we would have to wait too long - an indefinite period as the
	user may "sit" on the mouse button!
*/

var nowSubmitting = '';

function setNowSubmitting(typ) {
	// Note a form submission to suppress the onchange action - see neuWert()
	window.nowSubmitting = typ;
	// alert("setnowSubmitting: " + typ);
	return true;
}

// Decode the answer to a changed field value in the "Schnellsuche"
function tourData()
{
	// alert(xmlhttp.responseText);
	var xmlDocument = xmlhttp.responseXML;
	// Check for a modified value
	if (xmlDocument.getElementsByTagName("FLD")[0]) {
		// This can currently only be a normalised or rejected date
		var fld='', val='';
		fld = xmlDocument.getElementsByTagName("FLD")[0].childNodes[0].nodeValue;
		val = xmlDocument.getElementsByTagName("VAL")[0].childNodes[0].nodeValue;
		document.getElementById(fld).value = val;
		}
	// ANZAHL TOUREN - Insert the number of matching tours behind the button
	if (xmlDocument.getElementsByTagName("anztouren")[0])
	   set_anztouren(xmlDocument.getElementsByTagName("anztouren")[0].childNodes[0].nodeValue);
	// Display any message above the Schnellsuche
	if (xmlDocument.getElementsByTagName("MSG")[0]) {
		var msg='';
		msg = xmlDocument.getElementsByTagName("MSG")[0].childNodes[0].nodeValue;
		// Insert the message between div.schnellsuche and form-id 'toursuche'
		if (document.getElementById('toursuchemsg')) {
			var chld = document.getElementById('toursuchemsg');
			chld.firstChild.data = msg;
			}
		else {
			var myNode = document.createElement("p");
			// Give it the id attribute
			myNode.setAttribute('id', 'toursuchemsg');
			// Append the text node for the link
			var myText = document.createTextNode(msg);
			myNode.appendChild(myText);
			// Insert it into the DOM before the form
			var sblg = document.getElementById('toursuche');
			var prnt = sblg.parentNode;
			prnt.insertBefore(myNode,sblg);
			// IE positioning bug - button slips up, although posn "bottom"
			document.getElementById('panztouren').className = 'panztouren';
			document.getElementById('danztouren').className = 'danztouren';
			}
		}
	else {
		// Remove any old message
		if (document.getElementById('toursuchemsg')) {
			var chld = document.getElementById('toursuchemsg');
			var prnt = chld.parentNode;
			delTree(prnt,chld);
			// IE positioning bug - button slips down, although posn "bottom"
			document.getElementById('panztouren').className = 'panztouren';
			document.getElementById('danztouren').className = 'danztouren';
			}
		}
	return;
}

function ajaxFehler()
{
	alert("Fehler beim Notieren des neuen Feldwertes - Status " + xmlhttp.status);
	alert("Statusmeldung vom Server: " + xmlhttp.statusText);
	return;
}

function tourWertHttpState()
{
	if (xmlhttp.readyState == 4)
	{
		if ( xmlhttp.status == 200) {
			// daten erfolgreich geladen: starte Verarbeitung
			tourData();
		}
		else ajaxFehler();
	}
	return;
}

function vtsWertHttpState()
{
	if (xmlhttp.readyState == 4)
	{
		if ( xmlhttp.status == 200) {
			// Antwort erfolgreich - es gibt jedoch keine lokale Verarbeitung
			return;
		}
		else ajaxFehler();
	}
	return;
}

function neuWert(typ,fld) {
	// Pass a new form field value to it's session variable via AJAX
	// But don't do it if the form is being submitted anyway
	// Since onchange() and onkeyup() are called BEFORE onsubmit(), we must wait...
	// Bekannte Typen: 'v' => Volltextsuche; 't' => Toursuche; 'r' => Reiseleiter
	//                 'm' => Mitarbeiter
	// var debugTxt = "neuWert: " + typ + " für " + fld.name + ", nowSubmitting=" + window.nowSubmitting;
	// alert(debugTxt);		// Triggers onBlur
	// debugToPfad(debugTxt);
	if (! ajaxok) return;
	var aufruf = "neuWertWaited('" + typ + "','" + fld.id + "')";
	window.setTimeout(aufruf,5);
	return;
}

function neuWertWaited(typ,fldid) {
	// alert("neuWertWaited: " + typ + " für " + fldid + ", nowSubmitting=" + window.nowSubmitting);
	if (typ == window.nowSubmitting || ! ajaxok) return;
	xmlhttp = getXMLHttpRequest();
	// Call "set_formval.php" on the server to note new field value
	// Note that the response can be ignored for a VollTextSuche
	var fld = document.getElementById(fldid);
	var url = 'scripts/set_formval.php?fld=' + fld.name + '&val=' + escape(fld.value);
	xmlhttp.open("GET", prefix + url, true);
	// A request for Volltext- oder Toursuche
	xmlhttp.onreadystatechange = fld.name == "f_vtsuche" ? vtsWertHttpState : tourWertHttpState;
	xmlhttp.send(null);
	return;
}

function dummyHttp() {
	return;
}

// This is a generic function to write an entry to the web log (zB onclick PDF-Anzeige)
function weblog(kuerzel,p1,p2) {
	if (! ajaxok) return;
	xmlhttp = getXMLHttpRequest();
	// Call "weblog.php" on the server
	var url = '../scripts/weblog.php?kl=' + kuerzel + '&p1=' + p1 + '&p2=' + p2;
	xmlhttp.open("GET", url, true);
	xmlhttp.onreadystatechange = dummyHttp;
	xmlhttp.send(null);
	return;
}
