var wbb3 = {	
	xmlHttp : null,
	xmldata: null,
	container: null,
	init: function(id) {	
		if (document.getElementById(id)) {
			wbb3.container = document.getElementById(id);
            wbb3.container.className = "wbb3lp_container";
		}
	},
	laden: function(url) {
		if (wbb3.container) {	
			wbb3.xmlHttp = null;		
			var check = true;
			try {
			  wbb3.xmlHttp=new XMLHttpRequest();
			} catch (e) {
			  try {
			    wbb3.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  } catch (e) {
			    try {
			      wbb3.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			    } catch (e) {
			      // kein Ajax vorhanden!
			      wbb3.verstecken();
			      check = false;
			    }
			  }
			}
			// Anfrage Stellen
			if (check) {
				wbb3.xmlHttp.onreadystatechange=function() {
					if(wbb3.xmlHttp.readyState==4) {
					  	if (wbb3.xmlHttp.responseXML) {
						 	wbb3.xmldata = wbb3.xmlHttp.responseXML;
						 	wbb3.bearbeiten(wbb3.xmldata.getElementsByTagName("post"));
						 } else {
						 	// alert("Fehler: " + wbb3.xmlHttp.responseText.toString());
						 }
					}
				}
				wbb3.xmlHttp.open("GET",url,true);
				wbb3.xmlHttp.setRequestHeader('Content-Type', 'text/xml');        
				wbb3.xmlHttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
	  			wbb3.xmlHttp.send(null);
			}
		}
  	},
  	bearbeiten: function(xmlobj) {
  		if (xmlobj.length>0) {
  			var adder = null;                 
        	var neues = Array();
        	var felder = Array("threadID","topic","lastPoster");
        	for (var i=0;i<xmlobj.length;i++) {
        		// xml -> array
        		neues = Array();
        		for(var j=0;j<felder.length;j++) {
        			adder = xmlobj[i].getElementsByTagName(felder[j]);
        			if (adder[0]) {
        				neues[felder[j]] = adder[0].firstChild.nodeValue;
        				//alert(neues[felder[j]]);
        			}
        		}
        		wbb3.container.appendChild(wbb3.getHtmlElement(neues));
        	}
        } else {
        	wbb3.verstecken();
        }
        
  	},
  	getHtmlElement : function(daten) {
  		var elem = document.createElement("li");
  		var nad = document.createElement("a");
  		
  		elem.className = "wbb3lp_link";
  		
  		nad.className = "wbb3lp_link";
  		nad.appendChild(document.createTextNode(daten["topic"]));
  		nad.setAttribute("href","http://www.paninicomics.de/forum/index.php?page=Thread&threadID=" + daten["threadID"]  + "&action=lastPost");
  		
        //nad.setAttribute("href","http://www.paninicomics.de/forum3/index.php?page=Thread&threadID=" + daten["threadID"]  + "&action=lastPost");
  		
  		elem.appendChild(nad);
        nad = document.createElement("span");
  		nad.className = "wbb3lp_link";
  		nad.appendChild(document.createTextNode("von "+daten["lastPoster"]));
        elem.appendChild(nad);
        /*for(var item in daten) {
  			var nad = document.createElement("p");
  			nad.appendChild(document.createTextNode(item + " = " + daten[item]));
  			elem.appendChild(nad);
  		} */
  		return elem;
  	},
  	verstecken: function() {
  		// die Anzeige ausblenden : Kein Ajax oder Übertragungsfehler!
  		if (wbb3.container) {
  			wbb3.container.style.display = "none";
  			//alert("Verstecken!");
  		}
  	}
}
//wbb3.init();
//wbb3.laden("https://www.paninicomics.de/forum3/xml.php?sw=batman");

