/**
 * Copyright © 2004-2008 plentySystems GmbH  http://www.plentysystems.de/
 * All rights reserved.
 */


function plentyAjaxRequest(url) {

	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
	    http_request = new XMLHttpRequest();
	    if (http_request.overrideMimeType) {
	        http_request.overrideMimeType('text/xml');
	    }
	} else if (window.ActiveXObject) { // IE
	    try {
	        http_request = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch (e) {
	        try {
	            http_request = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (e) {}
	    }
	}

	if (!http_request) {
	    //alert('Internal Server Error (Code: AJAX 001)');
	    return false;
	}

	http_request.onreadystatechange = function() {

		if (http_request.readyState == 4 ) {
		    if (http_request.status == 200) {


		      if (window.ActiveXObject) {
		         var xml = new ActiveXObject("Microsoft.XMLDOM");
		         //The LoadXML method always takes a Unicode BSTR that is encoded in UCS-2 or UTF-16 only. If you pass in anything other than a valid Unicode BSTR to LoadXML, it will fail to load.
			     //responseText is ISO-8859-1!    http://msdn.microsoft.com/en-us/library/aa468560.aspx#xmlencod_topic2
			     //wir senden das XML jetzt einfach per UTF-8 und dann funzt es
		         xml.loadXML(http_request.responseText);
		      } else if (document.implementation) {
		         var xml = (new DOMParser()).parseFromString(http_request.responseText, "text/xml");
		      }

		    	/**
		    	 * get root
		    	 */
		    	var root = xml.getElementsByTagName('block')[0];
				var blocks = root.getElementsByTagName("blockNumIndex");

					for (var i = 0 ; i < blocks.length ; i++) {
						var block = blocks[i];
						
						if(block.getElementsByTagName("data")[0].getAttribute("base64")==1 ){
							//block.getElementsByTagName("data")[0].firstChild.nodeValue = base64_decode( block.getElementsByTagName("data")[0].firstChild.nodeValue );
						}
													
						if (block.getElementsByTagName("add")[0].firstChild.nodeValue == '1') {
							document.getElementById( block.getElementsByTagName("id")[0].firstChild.nodeValue ).innerHTML =
							document.getElementById( block.getElementsByTagName("id")[0].firstChild.nodeValue ).innerHTML + block.getElementsByTagName("data")[0].firstChild.nodeValue;
						} else {							
							document.getElementById( block.getElementsByTagName("id")[0].firstChild.nodeValue ).innerHTML = 
							block.getElementsByTagName("data")[0].firstChild.nodeValue;
						}
					}

		    } else {
		        //alert('Internal Server Error (Code: AJAX 002)');
		    }
		}
	};
	http_request.open('GET', url, true);
	http_request.send(null);
}




