var url = "/mod/Shop02/generateAjaxData.php"; // The server-side script
var url2 = "/mod/Shop02/updateAjaxData.php";
var url3 = "/mod/Shop02/updateAantalAjaxData.php";
var url4 = "/mod/Shop02/deleteAjaxData.php";
var http = getHTTPObject(); // We create the HTTP Object
var http2 = getHTTPObject(); // We create the HTTP Object

function requestCustomerInfo(nummer, aantal, extraQueryString) {
	if(!extraQueryString) {
		extraString = "";
	} else {
		extraString = extraQueryString;	
	}
	if(!nummer) {
		http.open("GET", url, true);
	} else {
		http.open("GET", url + "?id=" + escape(nummer) + "&aantal=" + escape(aantal) + extraString, true);
	}
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}
function updateCustomerInfo(articleId, optionCatId, optionValueId) {
	http.open("GET", url2 + "?id=" + escape(articleId) + "&optioncat=" + escape(optionCatId) + "&optionvalue=" + escape(optionValueId), true);
	http.onreadystatechange = handleHttpResponseAfrekenen;
	http.send(null);
}
function updateAantalCustomerInfo(articleId, aantal) {
	http2.open("GET", url3 + "?id=" + escape(articleId) + "&aantal=" + escape(aantal), true);
	http2.onreadystatechange = handleHttpResponseAfrekenen2;
	http2.send(null);
}
function deleteCustomerInfo(articleId) {
	http.open("GET", url4 + "?id=" + escape(articleId), true);
	http.onreadystatechange = handleHttpResponseAfrekenen;
	http.send(null);
}

function handleHttpResponse() {
	if (http.readyState == 4) {
		if(http.status == 200) {
			var results = http.responseText;
			document.getElementById('Shop02Mandje').innerHTML = results;
		}
	}
}
function handleHttpResponseAfrekenen() {
	if (http.readyState == 4) {
		if(http.status == 200) {
			var results = http.responseText;
			document.getElementById('Shop02afrekenArtikelenTabel').innerHTML = results;
		}
	}
}
function handleHttpResponseAfrekenen2() {
	if (http2.readyState == 4) {
		if(http2.status == 200) {
			var results = http2.responseText;
			document.getElementById('Shop02afrekenArtikelenTabel').innerHTML = results;
		}
	}
}
function getHTTPObject() {
	var xmlhttp;
	if(window.XMLHttpRequest){
		xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		if (!xmlhttp) {
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	}
	return xmlhttp;
}

