var xmlHttp = null;
	var xmlHttp1 = null;
	var xmlHttp2 = null;
	// Mozilla, Opera, Safari sowie Internet Explorer 7
	if (typeof XMLHttpRequest != 'undefined') {
	    xmlHttp = new XMLHttpRequest();
	}

	if (!xmlHttp) {
	    // Internet Explorer 6 und ?lter
	    try {
	        xmlHttp  = new ActiveXObject('Msxml2.XMLHTTP');
	    } catch(e) {
	        try {
	            xmlHttp  = new ActiveXObject('Microsoft.XMLHTTP');
	        } catch(e) {
	            xmlHttp  = null;
	        }
	    }
	}
	


	//Mozilla, Opera, Safari sowie Internet Explorer 7
	if (typeof XMLHttpRequest != 'undefined') {
	 xmlHttp1 = new XMLHttpRequest();
	}

	if (!xmlHttp1) {
	 // Internet Explorer 6 und ?lter
	 try {
	     xmlHttp1  = new ActiveXObject('Msxml2.XMLHTTP');
	 } catch(e) {
	     try {
	         xmlHttp1  = new ActiveXObject('Microsoft.XMLHTTP');
	     } catch(e) {
	         xmlHttp1  = null;
	     }
	 }
	}
	
	//Mozilla, Opera, Safari sowie Internet Explorer 7
	if (typeof XMLHttpRequest != 'undefined') {
	 xmlHttp2 = new XMLHttpRequest();
	}

	if (!xmlHttp2) {
	 // Internet Explorer 6 und ?lter
	 try {
	     xmlHttp2  = new ActiveXObject('Msxml2.XMLHTTP');
	 } catch(e) {
	     try {
	         xmlHttp2  = new ActiveXObject('Microsoft.XMLHTTP');
	     } catch(e) {
	         xmlHttp2  = null;
	     }
	 }
	}
	


var ok = false;

function readUserSuche() {
	
	
	if (xmlHttp) {
		xmlHttp.open('GET', "./ajax/usersuche.php?suche=" + suche, true);
		xmlHttp.onreadystatechange = GetUserData;
		
		xmlHttp.send(null);

	}
	

}


var ausgabe = 0;
// Lese Benutzerdaten
function GetUserData() {
	var inhalt="" ;
	if (xmlHttp.readyState == 4) {
		
		 var liste = document.getElementById("benutzersuche");
		 var userdatenxml = xmlHttp.responseXML;
		 if(!userdatenxml) {
			 alert("Benutzer keine daten"+userdatenxml);
			 return
		 }
		 
		 var userdaten = userdatenxml.getElementsByTagName("userinfo");
		 ausgabe = userdaten.length;
		 if(ausgabe) {
			 inhalt += '<table border=0>';
			 inhalt += "<tr><td colspan='3'>Benutzersuche</td></tr>";
		 }
		for(var i=0;i < userdaten.length;i++) {
			var user, id, shopid;
	        var userinfo = userdaten[i];
	         for (var j = 0; j < userinfo.childNodes.length; j++) {
	            with (userinfo.childNodes[j]) {
	               if (nodeName == "user") {
	                  user = firstChild.nodeValue;
	               } else if (nodeName == "id") {
	            	   id = firstChild.nodeValue;
	               }	else if (nodeName == "shopid") {
	            	   shopid = firstChild.nodeValue;
	               }
	            }
	         }
	         
	         if(shopid==0) {
	        	 inhalt += "<tr><td width='150'>"+user+"</td><td colspan='2'><a href='./?page=profil&profilid="+id+"'>Profil</a></td></tr>";
	         } else {
	        	 inhalt += "<tr><td width='150'>"+user+"</td><td width=50><a href='./?page=profil&profilid="+id+"'>Profil</a></td><td><a href='./?page=shop&shopid="+shopid+"'>Shop</a></td></tr>";
	         }
	         }
		inhalt += "</table>";
	    
		
		benutzersuchefenster.innerHTML = benutzersuchefenster.innerHTML+inhalt;
		ok = true;
		xmlHttp = null;
		
	}
	
}


function readArtikelSuche() {
	ok = false;
	
	if (xmlHttp1) {
		xmlHttp1.open('GET', "./ajax/artikelsuche.php?suche=" + suche, true);
		xmlHttp1.onreadystatechange = GetArtikelData;
		
		xmlHttp1.send(null);

	}
	
	
}
var ausgabe = 0;
// Lese Benutzerdaten
function GetArtikelData() {
	var inhalt="" ;
	
	if (xmlHttp1.readyState == 4) {
		
		 //var liste = document.getElementById("artikeldaten");
		 //var artikeldatenxml = xmlHttp1.responseText;
		var artikeldatenxml = xmlHttp1.responseXML;
		 if(!artikeldatenxml) {
			 alert("Artikelsuche");
			 return;
		 }
		
		 var daten = artikeldatenxml.getElementsByTagName("artikelinfo");
		 ausgabe = daten.length;
		 if(ausgabe) {
			 inhalt += '<table border=0>';
			 inhalt += "<tr><td colspan='3' class='formtext zellenfarbe'>Artikelsuche</td></tr>";
		 }
			 
		for(var i=0;i < daten.length;i++) {
			var id, artikelname, anzahl,preis,vorschaubild,shopcategoryid,shopid;
	        var info = daten[i];
	         for (var j = 0; j < info.childNodes.length; j++) {
	            with (info.childNodes[j]) {
	               if (nodeName == "artikelname") {
	                  artikelname = firstChild.nodeValue;
	               } else if (nodeName == "vorschaubild") {
	            	   if(firstChild) {vorschaubild = firstChild.nodeValue;} else { vorschaubild="./resource/img/keinbild_vorschau.png"; }
	               } else if (nodeName == "preis") {
	            	   preis = firstChild.nodeValue;
	               }
	               else if (nodeName == "id") {
	            	   id = firstChild.nodeValue;
	               } else if (nodeName == "preis") {
	            	   preis = firstChild.nodeValue;
	               } else if (nodeName == "anzahl") {
	            	   anzahl = firstChild.nodeValue;
	               } else if (nodeName == "shopcategoryid") {
	            	   shopcategoryid = firstChild.nodeValue;
	               } else if (nodeName == "shopid") {
	            	   shopid = firstChild.nodeValue;
	               }
	               
	            }
	         }
	        
	        if(anzahl != "0") {
		         inhalt += "<tr><td width='60' rowspan='3'><a href='./?page=artikel&id="+id+"&shopcate="+shopcategoryid+"&shopid="+shopid+"'><img  src='./imageviewer.php?img="+vorschaubild.substring(1,vorschaubild.length)+"&x=60&y=60' alt='"+artikelname+"' title='"+artikelname+"'></a></td><td class='artikel' colspan='2'><a href='./?page=artikel&id="+id+"&shopcate="+shopcategoryid+"&shopid="+shopid+"'>"+artikelname+"</a></td></tr>";
		         inhalt += "<tr><td class='artikeltext' width='50'>Anzahl</td><td class='artikeltext1'>"+anzahl+"</td></tr><tr><td class='artikeltext'>Preis</td><td class='artikeltext1'>"+preis+"</td></tr>";
	        }
	         }
		inhalt += "</table>";
	    
		
		benutzersuchefenster.innerHTML = benutzersuchefenster.innerHTML+inhalt;
		ok = true;
	}
	
}

function wait() {
	if(!ok) {
		setTimeout("wait()",2000);
	}
}


function noData() {
	
	if(ausgabe == 0) {
		var rahmen = document.getElementById('suche');
		rahmen.innerHTML ="Keine Daten gefunden";
	} else {
		rahmen.innerHTML ="";
	}
	
}


