function printOut()
  {
  window.print();
  }
 var xmlDoc;
 function lesen(uri) {
      if (window.ActiveXObject) {
          //IE
          xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      }
      else
          if (!(xmlDoc = document.implementation.createDocument("", "", null))) {
              alert("Kann XML nicht lesen!");
              return;
          }
      xmlDoc.async = false;
      xmlDoc.load(uri);
  }
  function getArrayfromXML() {
      var XMLArray = new Array();
      var IDNode = xmlDoc.getElementsByTagName("id");
      var NameNode = xmlDoc.getElementsByTagName("titel");
      var maxTreffer = 10;

      //alert(NameNode[0].firstChild.nodeValue);
      for (var i = 0; i < IDNode.length; i++) {
          IDVar = IDNode[i].firstChild.nodeValue;
          NameVar = NameNode[i].firstChild.nodeValue;
          XMLArray[i] = new Object();
          XMLArray[i]["id"] = IDVar;
          XMLArray[i]["titel"] = NameVar;
      }
      if (maxTreffer >= i) {
          for (var y = i; y < maxTreffer; y++) {
              XMLArray[y] = new Object();
              XMLArray[y]["id"] = "";
              XMLArray[y]["titel"] = "";
          }
      }
      return XMLArray;
  }
  function fillBox() {
      if (document.suchform.search.value == "")
          document.getElementById("vorschlagdiv").style.visibility = "hidden";
      else
          document.getElementById("vorschlagdiv").style.visibility = "inherit";
      //Auslesen Formular
      uri = "/xml.php?suche=" + document.suchform.search.value;
      lesen(uri);
      info = getArrayfromXML();
      window.document.suchform.v1.value = info[0]["titel"];
      window.document.suchform.v2.value = info[1]["titel"];
      window.document.suchform.v3.value = info[2]["titel"];
      window.document.suchform.v4.value = info[3]["titel"];
      window.document.suchform.v5.value = info[4]["titel"];
      window.document.suchform.v6.value = info[5]["titel"];
      window.document.suchform.v7.value = info[6]["titel"];
      window.document.suchform.v8.value = info[7]["titel"];
      window.document.suchform.v9.value = info[8]["titel"];
      window.document.suchform.v0.value = info[9]["titel"];
  }
  function overit(obj) {
      inp = document.getElementById(obj);
      inp.style.cursor = "pointer";
      inp.style.backgroundColor = "#e40476";
  }
  function outit(obj) {
      inp = document.getElementById(obj);
      inp.style.cursor = "default";
      inp.style.backgroundColor = "#ffffff";
  }
  function auswahl(obj) {
      inp = document.getElementById(obj);
      window.document.suchform.search.value = inp.value;
      document.getElementById("vorschlagdiv").style.visibility = "hidden";
  }
  function lshow() {
      par_span = document.getElementById("lieferbed");
      par_span_x = par_span.style.left;
      par_span_y = par_span.style.top;
      info_div = document.getElementById("lieferbedinfo");
      info_div.style.left = par_span_x;
      info_div.style.top = par_span_y;
      info_div.style.visibility = "inherit";
  }
  function lhide() {
      document.getElementById("lieferbedinfo").style.visibility = "hidden";
  }
  
function getArrayfromXML_WB()
{
	var XMLArray = new Array();
	var IDNode = xmlDoc.getElementsByTagName("lagernd");
	var maxTreffer=1;
	
	//alert(NameNode[0].firstChild.nodeValue);
	for (var i=0; i < IDNode.length; i++)
	{
		IDVar = IDNode[i].firstChild.nodeValue;
		XMLArray[i] = new Object();
		XMLArray[i]["lagernd"]= IDVar;
	}
	if (maxTreffer >= i)
	{
		for (var y = i; y < maxTreffer; y++) 
		{
			XMLArray[y] = new Object();
			XMLArray[y]["lagernd"]= "";
		}
	}
	return XMLArray;
}
function chkAvail(fname, me) 
{
    if (fname == "preis1")
    {
        anz = document.preis1.anzahl.value * me;
        id = document.preis1.prod.value;
    }
    if (fname == "preis2") {
        anz = document.preis2.anzahl.value * me;
        id = document.preis2.prod.value;
    }
    if (fname == "preis3") {
        anz = document.preis3.anzahl.value * me;
        id = document.preis3.prod.value;
    }
    //Auslesen Formular
    uri = "/xmlwb.php?id=" + id + "&stk=" + anz;
    //alert(uri);
	lesen(uri);
	info = getArrayfromXML_WB();
	if (info[0]["lagernd"] == 1)
    {
	    //document.getElementById("ampel").style.backgroundColor = "#00ff00";
        document.getElementById("ampel").style.visibility = "inherit";
        window.document.ampelpic.src = "/upload/sitepic/gruen.jpg";
        window.document.ampelpic.alt = "Ware lagernd";
    }
	else 
    {
//        document.getElementById("ampel").style.backgroundColor = "#ff0000";
        document.getElementById("ampel").style.visibility = "inherit";
        document.getElementById("ampelpic").src = "/upload/sitepic/rot.jpg";
        window.document.ampelpic.alt = "10-14 Tage Lieferzeit";
    }
}

function ch_payment(show_pay) {
    pdiv = document.getElementById("opay");
    wkdiv = document.getElementById("wk_besteller");
    if (show_pay == 1)
    {
        pdiv.style.height=160+"px";
        pdiv.style.visibility = "inherit";
        wkdiv.style.height=0+"px";
        wkdiv.style.visibility="hidden";
    }
    else
    {
        pdiv.style.height=0+"px";
        pdiv.style.visibility="hidden";
        wkdiv.style.height=160+"px";
        wkdiv.style.visibility = "inherit";
    }
}
function showCover() {
    document.getElementById("dark").style.visibility = 'inherit';
    document.getElementById("cont").style.visibility = 'inherit';
    document.getElementById("olzahlung").style.visibility='hidden';
    window.setTimeout("payTimeout()", 1000);
}

function payTimeout() {
    if (document.getElementById("status").value == "Status: SUCCESS") {
        //alert(document.getElementById("status").value)
        document.submitit.submit();
        return -1;
    }
    window.setTimeout("payTimeout()", 1000);
}

function mouseX(evt) {
    if (evt.pageX) return evt.pageX;
    else if (evt.clientX)
        return evt.clientX + (document.documentElement.scrollLeft ?
    document.documentElement.scrollLeft :
    document.body.scrollLeft);
    else return null;
}
function mouseY(evt) {
    if (evt.pageY) return evt.pageY;
    else if (evt.clientY)
        return evt.clientY + (document.documentElement.scrollTop ?
    document.documentElement.scrollTop :
    document.body.scrollTop);
    else return null;
}

function ShowHideBesteck(id, stat) {
    if (stat == 0) {
        document.getElementById(id).style.visibility = "hidden";
    }
    else {
        var e = window.event
        document.getElementById(id).style.visibility = "inherit";
        //alert(mouseX(e) + "..." + mouseY(e));
        document.getElementById(id).style.top = mouseY(e) + "px";
        document.getElementById(id).style.left = mouseX(e) + "px";
    }

}
