var xmlHttp;

function suggest(suchbegriff) {
xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}
if (suchbegriff.length == 0) { 
  document.getElementById("ausgabe").innerHTML="";
  return;
}
else {
	//URL vorbereiten, Zufallszahl umgeht den Browsercache  
	//document.getElementById('indicator').style.display = 'block';
	var aufruf="makesql.asp"+"?a=1"+suchbegriff+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
	}
} 
function stateChanged() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.getElementById("ausgabe").innerHTML=xmlHttp.responseText;
 //document.getElementById('indicator').style.display = 'none';
 } 
}


// Lieferantenliste
function lf30Liste(suchbegriff) {
xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}

else {
	//URL vorbereiten, Zufallszahl umgeht den Browsercache  
	document.getElementById('indicator').style.display = 'block';
	var aufruf="sql30Lieferanten.asp"+"?a=1"+suchbegriff+"&sid="+Math.random();
	xmlHttp.onreadystatechange=showKdListe;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
	}
} 

// Angebote
function sqlB00an(suchbegriff) {
xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}

else {
	//URL vorbereiten, Zufallszahl umgeht den Browsercache
	document.getElementById('indicator').style.display = 'block';
	var aufruf="sqlB00an.asp"+"?a=1"+suchbegriff+"&sid="+Math.random();
	xmlHttp.onreadystatechange=showKdListe;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
	}
}


// Service Technik
function sql40Technik(suchbegriff) {

//xLang=(document.getElementById('lfSrt').value.length)+4;
xLang=(document.getElementById('tecArtikel').value.length);
xOK=suchbegriff.indexOf("ref=");

xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}
if ( document.getElementById('tecArtikel').value > '' && xLang < 2  && xOK < 0) { 
  document.getElementById("ausgabe").innerHTML="";
  return;
}
else {
	//URL vorbereiten, Zufallszahl umgeht den Browsercache  
	document.getElementById('indicator').style.display = 'block';
	var aufruf="sql40Technik.asp"+"?a=1"+suchbegriff+"&sid="+Math.random();
	
	
	xmlHttp.onreadystatechange=showKdListe;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
	}
} 

function showKdListe() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.getElementById("ausgabe").innerHTML=xmlHttp.responseText;
 document.getElementById('indicator').style.display = 'none';
 } 
}





// Artikelliste f³r Vorgõnge
function artListe(suchbegriff) {
xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}
if (suchbegriff.length < 10) { 
  document.getElementById("ausgabeArtikel").innerHTML="";
  return;
}
else {
	//URL vorbereiten, Zufallszahl umgeht den Browsercache  
	document.getElementById('indicator').style.display = 'block';
	var aufruf="sqlArtikel.asp?a=1"+suchbegriff+"&sid="+Math.random();
	
	
	xmlHttp.onreadystatechange=showArtListe;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
	}
} 

// Artikelliste f³r a0020
function art20Liste(suchbegriff) {
// alert(suchbegriff.length);
// xLang=(document.getElementById('artikelSort').value.length)+80;
xLang=(document.getElementById('artikelName').value.length);
xOK=suchbegriff.indexOf("ref=");
xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}
if ( document.getElementById('artikelName').value > '' && xLang < 2  && xOK < 0) { 
  document.getElementById("ausgabeArtikel").innerHTML="";
  return; 
  document.getElementById("ausgabeArtikel").innerHTML="";
  return;
}
else {

	//URL vorbereiten, Zufallszahl umgeht den Browsercache  
	document.getElementById('indicator').style.display = 'block';
	var aufruf="sql20Artikel.asp?a=1"+suchbegriff+"&sid="+Math.random();
	
	
	xmlHttp.onreadystatechange=showArtListe;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
	}
} 


function showArtListe() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.getElementById("ausgabeArtikel").innerHTML=xmlHttp.responseText;
 document.getElementById('indicator').style.display = 'none';
 } 
}


// Artikel Bestellen
function ajSetBestellung(varArtnr) {
var iArtnr;
var sChecked;
iArtnr=varArtnr;

wahr=(document.getElementById('art'+iArtnr).checked);
xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}
//

var aufruf="ajSetBestellung.asp?a=" + wahr + "&artnr=" + iArtnr +"&sid="+Math.random();
	xmlHttp.onreadystatechange=korbinfo;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
//
}

function korbinfo() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.getElementById("gekauft").innerHTML=xmlHttp.responseText;
 } 
}



// Artikel Anfragen
function ajSetAnfrage(varArtnr) {
var iArtnr;
var sChecked;
iArtnr=varArtnr;

wahr=(document.getElementById('Anfrage'+iArtnr).checked);
xmlHttp=httpXMLobjects();
if (xmlHttp==null) {
  alert ("Browser does not support AJAX");
  return;
}
//

var aufruf="ajSetAnfrage.asp?a=" + wahr + "&artnr=" + iArtnr +"&sid="+Math.random();
	xmlHttp.onreadystatechange=angefragt;
	xmlHttp.open("GET",aufruf,true);
	xmlHttp.send(null);
//
}

function angefragt() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.getElementById("angefragt").innerHTML=xmlHttp.responseText;
 } 
}





//AJAX-Standards 

function httpXMLobjects() {
var xmlHttp=null;
try {
 // Fuer Firefox, Opera und Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e) {
 // Der Internet Explorer wills wieder anders
 try {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e) {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}



