



/*
-----code von wiki ------
var xmlHttp = null;
try {
    // Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
    xmlHttp = new XMLHttpRequest();
} catch(e) {
    try {
        // MS Internet Explorer (ab v6)
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        try {
            // MS Internet Explorer (ab v5)
            xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            xmlHttp  = null;
        }
    }
}
if (xmlHttp) {
    xmlHttp.open('GET', 'beispiel.xml', true);
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4) {
            alert(xmlHttp.responseText);
        }
    };
    xmlHttp.send(null);
}

*/

// find & return XmlHttpObject
function GetXmlHttpObject(){ 
	var objXMLHttp = null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}



///////////////////////////////////////////////////////////////////////
// get remote movie details, searching by id
function cartUpdate(artikelNummer){

	document.getElementById('cartfb_' + artikelNummer).src = urlimg + 'cart/progress.gif';

	itemCount = document.getElementById('cartadd_' + artikelNummer).value;
	if (itemCount == ''){ itemCount = 0; }

	oldValue = document.getElementById('cartadd_' + artikelNummer).value;

	//alert(artikelNummer + ' = ' + itemCount);


	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}

	var url= urlbase + "db_front/cart_ajax.php";
	url=url+"?proart=" + artikelNummer;
	url=url+"&oldvalue=" + oldValue;
	url=url+"&cnt=" + itemCount;
	url=url+"&dummy=" + Math.random();
	xmlHttp.onreadystatechange = cartUpdate_process;

	//alert(url);
	xmlHttp.open('GET',url,true);
	xmlHttp.send(null);

}



function cartUpdate_process(){

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		xmlDoc = xmlHttp.responseXML;
//alert(xmlHttp.responseText);
		cartUpdate_feedback(xmlDoc);		// display on page
	}

}

function cartUpdate_feedback(xmlDoc){

		oldvalue = '';
		errormessage = '';

		if (xmlDoc.getElementsByTagName("art")[0].hasChildNodes()){
			artnum = xmlDoc.getElementsByTagName("art")[0].childNodes[0].nodeValue;
		}


		if (xmlDoc.getElementsByTagName("oldvalue")[0].hasChildNodes()){
			oldvalue = xmlDoc.getElementsByTagName("oldvalue")[0].childNodes[0].nodeValue;
		}


		if (xmlDoc.getElementsByTagName("newcount")[0].hasChildNodes()){
			newcount = xmlDoc.getElementsByTagName("newcount")[0].childNodes[0].nodeValue;
			if (oldvalue){
				document.getElementById('cartadd_' + artnum).value = newcount;
			}
		}

		if (newcount >0){
			document.getElementById('cartfb_' + artnum).src = urlimg + 'cart/ok.gif';
		}else{
			document.getElementById('cartfb_' + artnum).src = urlimg + 'cart/void.gif';
		}

		if (xmlDoc.getElementsByTagName("cartstring")[0].hasChildNodes()){
			document.getElementById('carttext').innerHTML = xmlDoc.getElementsByTagName("cartstring")[0].childNodes[0].nodeValue;
		}

		if (xmlDoc.getElementsByTagName("errormessage")[0].hasChildNodes()){
			alert(xmlDoc.getElementsByTagName("errormessage")[0].childNodes[0].nodeValue);
		}


}
