 // stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject();



// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject()
{
   // will store the reference to the XMLHttpRequest object
   var xmlHttp;
   // if running Internet Explorer
   if(window.ActiveXObject)
   {
      try
      {
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
         xmlHttp = false;
      }
   }
   // if running Mozilla or other browsers
   else
   {
      try
      {
         xmlHttp = new XMLHttpRequest();
      }
      catch (e)
      {
         xmlHttp = false;
      }
   }
   // return the created object or display an error message
   if (!xmlHttp)
      alert("Error creating the XMLHttpRequest object.");
   else
      return xmlHttp;
}
// make asynchronous HTTP request using the XMLHttpRequest object
function process()
{
   // proceed only if the xmlHttp object isn't busy
   if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
   {
      // retrieve the search typed by the search on the form
      var hersteller = escape(document.getElementById("hersteller").options[document.getElementById('hersteller').selectedIndex].value);
      var produktgruppe = escape(document.getElementById("produktgruppe").options[document.getElementById('produktgruppe').selectedIndex].value);
      var lang = escape(document.getElementById("lang").value);





document.getElementById("produkt").length = null;


if(document.getElementById("lang").value == 1) {
NeuerEintrag = new Option("Bitte w\u00e4hlen", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};

if(document.getElementById("lang").value == 2) {
NeuerEintrag = new Option("Choose please", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};

if(document.getElementById("lang").value == 3) {
NeuerEintrag = new Option("Selezionare prima il produttore", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};


if(document.getElementById("lang").value == 4) {
NeuerEintrag = new Option("Choisissez d`abord votre fabricant", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};



/*
document.getElementById("produkt").length = null;



if(document.getElementById("lang").value == 1) {
NeuerEintrag = new Option("Bitte erst den Hersteller w\u00e4hlen", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};

if(document.getElementById("lang").value == 2) {
NeuerEintrag = new Option("Choose please", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};

if(document.getElementById("lang").value == 3) {
NeuerEintrag = new Option("Selezionare prima il prodotto", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};

if(document.getElementById("lang").value == 4) {
NeuerEintrag = new Option("Choisissez d`abord votre fabricant", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};
*/






document.getElementById("dlcontent").innerHTML = "";

       // execute the hersteller.php page from the server
      xmlHttp.open("GET", "hersteller.php?hersteller=" + hersteller + "&lang="+lang+"&produktgruppe="+produktgruppe, true);
      // define the method to handle server responses
      xmlHttp.onreadystatechange = handleServerResponse;
      // make the server request
      xmlHttp.send(null);
   }
   else {
      // if the connection is busy, try again after one second
      // setTimeout('process()', 10000);
   };
}




// executed automatically when a message is received from the server
function handleServerResponse()
{
   // 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;
	// gets document root
	xmlRoot = xmlResponse.documentElement;




	// reading the content
	arrid = xmlRoot.getElementsByTagName("id");
	arrsprache = xmlRoot.getElementsByTagName("sprache");
	arrhersteller = xmlRoot.getElementsByTagName("hersteller");
	arrproduktgruppe = xmlRoot.getElementsByTagName("produktgruppe");
	arrfilename = xmlRoot.getElementsByTagName("filename");
	arrtimestamp = xmlRoot.getElementsByTagName("timestamp");
	arrsort_id = xmlRoot.getElementsByTagName("sort_id");
	arrtype = xmlRoot.getElementsByTagName("type");
	arrlinkname = xmlRoot.getElementsByTagName("linkname");





var counter = 1;


var content = "";





/*
var a = document.getElementById("hersteller").options.length;


for(i=0; i<a; i++) {



document.getElementById("produkt").options[1] = null;

if(document.getElementById("lang").value == 1) {
NeuerEintrag = new Option("Bitte w\u00e4hlen", "0", false, true);
};

if(document.getElementById("lang").value == 2) {
NeuerEintrag = new Option("Choose please", "0", false, true);
};

if(document.getElementById("lang").value == 3) {
NeuerEintrag = new Option("Selezionare prima il produttore", "0", false, true);
};

if(document.getElementById("lang").value == 4) {
NeuerEintrag = new Option("Choisissez d`abord votre fabricant", "0", false, true);
};






document.getElementById("produkt").options[0] = NeuerEintrag;

};
*/







	 for(var i=0; i<arrid.length; i++) {


// defines used variables
var id = '';
var sprache = '';
var hersteller = '';
var produktgruppe = '';
var filename = '';
var timestamp = '';
var sort_id = '';
var type = '';
var linkname = '';






if (arrid.item(i).hasChildNodes())
{
id = arrid.item(i).firstChild.data;
};

if (arrsprache.item(i).hasChildNodes())
{
sprache = arrsprache.item(i).firstChild.data;
};

if (arrhersteller.item(i).hasChildNodes())
{
hersteller = arrhersteller.item(i).firstChild.data;
};

if (arrproduktgruppe.item(i).hasChildNodes())
{
produktgruppe = arrproduktgruppe.item(i).firstChild.data;
};

if (arrfilename.item(i).hasChildNodes())
{
filename = arrfilename.item(i).firstChild.data;
};


if (arrtimestamp.item(i).hasChildNodes())
{
timestamp = arrtimestamp.item(i).firstChild.data;
};


if (arrsort_id.item(i).hasChildNodes())
{
sort_id = arrsort_id.item(i).firstChild.data;
};


if (arrtype.item(i).hasChildNodes())
{
type = arrtype.item(i).firstChild.data;
};


if (arrlinkname.item(i).hasChildNodes())
{
linkname = arrlinkname.item(i).firstChild.data;
};



NeuerEintrag = new Option(filename, id, false, true);

document.getElementById("produkt").options[counter] = NeuerEintrag;





counter++;
	 };



/*
if(counter > 1) {

if(document.getElementById("lang").value == 1) {
NeuerEintrag = new Option("Alle anzeigen", "showall", false, true);
document.getElementById("produkt").options[counter] = NeuerEintrag;
document.getElementById("produkt").options[0].text = "Bitte w\u00e4hlen";
};

if(document.getElementById("lang").value == 2) {
NeuerEintrag = new Option("Show all", "showall", false, true);
document.getElementById("produkt").options[counter] = NeuerEintrag;
document.getElementById("produkt").options[0].text = "Choose please";
};


if(document.getElementById("lang").value == 3) {
NeuerEintrag = new Option("Mostra tutti", "showall", false, true);
document.getElementById("produkt").options[counter] = NeuerEintrag;
document.getElementById("produkt").options[0].text = "Selezionare";
};

if(document.getElementById("lang").value == 4) {
NeuerEintrag = new Option("Afficher tous", "showall", false, true);
document.getElementById("produkt").options[counter] = NeuerEintrag;
document.getElementById("produkt").options[0].text = "SVP choisissez";
};


};
*/



document.getElementById("produkt").selectedIndex = 0;



         // update the client display using the data received from the server

         // restart sequence
         // setTimeout('process()', 1000000000000);
      }
      // a HTTP status different than 200 signals 
      else
      {
       //  alert("There was a problem accessing the server: " + xmlHttp.statusText);
      }
   }
} 


