

function getEndlicher()
{
	// callerval: the current id of the calling element's ENTRY
	// tbl: the table opened when the call was issued i.e. the DB context in which the calling element is embedded in
	// uptbl: the table where the the calling element takes its values from
	// *** IMPORTANT: there are (at least one) more arguments passed to this function = dependent elements to be updated by the call
	//alert ("getting");
	var URI = "commoninc/_getEndlicker.php";
	
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
    	//alert (URI);
		//document.write (URI);
		xmlHttp.open("GET", URI , true);
		xmlHttp.onreadystatechange = setEndlicher;
		xmlHttp.send(null);
	}
    else 
    {
       setTimeout('getEndlicher()', 1000);
    }
  
}




function setEndlicher()
{
 //alert ("setting");
 if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlRoot = xmlResponse.documentElement;
      elementsArray = xmlRoot.getElementsByTagName("name");
	  var endlicher = 0;
	  for (var i=0;i<elementsArray.length;i++)
	  {
	  	endlicher = unescape(elementsArray.item(i).firstChild.data);
	  }
	  if (document.getElementById("endlicker") && endlicher!=0) document.getElementById("endlicker").innerHTML = endlicher;
	  setTimeout('getEndlicher()', 5000);
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("getEndlicher(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function doUpdateFieldSelect()
{
 if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlRoot = xmlResponse.documentElement;
	  optionsArray = xmlRoot.firstChild.data.split(";");
	  if (document.getElementById('REF_FLD'))
	  {
	  document.getElementById('REF_FLD').options.length=null;
	document.getElementById('REF_FLD').options.length=optionsArray.length;

			for (var j=0;j<optionsArray.length;j++)
			{
			var theOpts = optionsArray[j].split(",");
			var Opt = new Option(unescape(theOpts[1]),theOpts[0],false,false);
			document.getElementById('REF_FLD').options[j]=Opt;
			}
			}
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("doUpdateFieldSelect(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }

}

// executed automatically when a message is received from the server
function handleServerResponseXX() 
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
      xmlResponse = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlDocumentElement = xmlResponse.documentElement;
      // get the text message, which is in the first child of
      // the the document element
      helloMessage = xmlDocumentElement.firstChild.data;
      // update the client display using the data received from the server
      document.getElementById("divMessage").innerHTML = 
                                            '<i>' + helloMessage + '</i>';
      // restart sequence
      setTimeout('process()', 1000);
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("handleServerResponse(): There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function decode_utf8(utftext) {
    var plaintext = ""; var i=0; var c=c1=c2=0;
    // while-Schleife, weil einige Zeichen uebersprungen werden
    while(i<utftext.length)
        {
      c = utftext.charCodeAt(i);
        if (c<128) {
             plaintext += String.fromCharCode(c);
            i++;}
         else if((c>191) && (c<224)) {
            c2 = utftext.charCodeAt(i+1);
             plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
             i+=2;}
         else {
            c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
             plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
             i+=3;}
         }
     return plaintext;
 }
 
 function showBildUndText(pos)
{
document.getElementById("kat_"+katpos).className="";
document.getElementById("kleintext").innerHTML=unescape(kleintexte[pos]);
document.getElementById("kleinbild").src=kleinbilder[pos];
//alert( kleinbilder[pos]);
katpos=pos;
document.getElementById("kat_"+katpos).className="current";
}

function nl2br(str)
{
//alert("x");
str=str.replace(/char(10)/,"<br />");
return str.replace(/char(13)/,"<br />");

}

function switchTitle(el){
hiPicTit=el.getAttribute('title');
el.setAttribute('title',el.getAttribute('shorttitle'));
}

function reswitchTitle(el){
el.setAttribute('title',hiPicTit);
}