 // stores the reference to the XMLHttpRequest object
var xmlHttpprodukt = createXmlHttpRequestObjectprodukt();



// retrieves the XMLHttpRequest object
function createXmlHttpRequestObjectprodukt()
{
   // will store the reference to the XMLHttpRequest object
   var xmlHttpprodukt;
   // if running Internet Explorer
   if(window.ActiveXObject)
   {
      try
      {
         xmlHttpprodukt = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e)
      {
         xmlHttpprodukt = false;
      }
   }
   // if running Mozilla or other browsers
   else
   {
      try
      {
         xmlHttpprodukt = new XMLHttpRequest();
      }
      catch (e)
      {
         xmlHttpprodukt = false;
      }
   }
   // return the created object or display an error message
   if (!xmlHttpprodukt)
      alert("Error creating the XMLHttpRequest object.");
   else
      return xmlHttpprodukt;
}
// make asynchronous HTTP request using the XMLHttpRequest object
function process_produkt()
{
   // proceed only if the xmlHttp object isn't busy
   if (xmlHttpprodukt.readyState == 4 || xmlHttpprodukt.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(lang == 1) {
NeuerEintrag = new Option("Bitte erst Produktgruppe wählen", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};


if(lang == 2) {
NeuerEintrag = new Option("Choose a product group first", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};

if(lang == 3) {
NeuerEintrag = new Option("Selezionare prima il prodotto", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};

if(lang == 4) {
NeuerEintrag = new Option("Choisissez d`abord votre gamme de produit", "0", false, true);
document.getElementById("produkt").options[0] = NeuerEintrag;
};


document.getElementById("dlcontent").innerHTML = "";




       // execute the produkt.php page from the server
      xmlHttpprodukt.open("GET", "produkt.php?hersteller=" + hersteller + "&lang="+lang+"&produktgruppe="+produktgruppe, true);
      // define the method to handle server responses
      xmlHttpprodukt.onreadystatechange = handleServerResponseprodukt;
      // make the server request
      xmlHttpprodukt.send(null);
   }
   else {
      // if the connection is busy, try again after one second
      // setTimeout('process_produkt()', 10000);
   };
}




// executed automatically when a message is received from the server
function handleServerResponseprodukt()
{
   // move forward only if the transaction has completed
   if (xmlHttpprodukt.readyState == 4)
   {
      // status of 200 indicates the transaction completed successfully
      if (xmlHttpprodukt.status == 200)
      {
	// extract the XML retrieved from the server
	xmlResponse = xmlHttpprodukt.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");





var counter = 1;


var content = "";






var a = document.getElementById("produkt").options.length;


if(document.getElementById("lang").value == 1) {

for(i=0; i<a; i++) {



document.getElementById("produkt").options[i] = null;


NeuerEintrag = new Option("Bitte erst Produktgruppe wählen", "0", false, true);

document.getElementById("produkt").options[0] = NeuerEintrag;

};


}; // ende lang 1



if(document.getElementById("lang").value == 2) {

for(i=0; i<a; i++) {



document.getElementById("produkt").options[i] = null;


NeuerEintrag = new Option("Choose a product group first", "0", false, true);

document.getElementById("produkt").options[0] = NeuerEintrag;

};


}; // ende lang 2







if(document.getElementById("lang").value == 3) {

for(i=0; i<a; i++) {



document.getElementById("produkt").options[i] = null;


NeuerEintrag = new Option("Selezionare prima il prodotto", "0", false, true);

document.getElementById("produkt").options[0] = NeuerEintrag;

};


}; // ende lang 3





if(document.getElementById("lang").value == 4) {

for(i=0; i<a; i++) {



document.getElementById("produkt").options[i] = null;


NeuerEintrag = new Option("Choisissez d`abord votre gamme de produit", "0", false, true);

document.getElementById("produkt").options[0] = NeuerEintrag;

};


}; // ende lang 4









	 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 = "";





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;
};



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ählen";
};

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;
document.getElementById("produkt").selectedIndex = 0;


         // update the client display using the data received from the server

         // restart sequence
         // setTimeout('process_produkt()', 1000000000000);
      }
      // a HTTP status different than 200 signals 
      else
      {
       //  alert("There was a problem accessing the server: " + xmlHttpprodukt.statusText);
      }
   }
} 

