var  xmlHttpFav;

function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		 xmlHttpFav = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		 xmlHttpFav = new XMLHttpRequest();
	}
}

// doe request naar php
function getItems() {
	url = "_ajax_get_bestel_items.php?" + Math.random()*9999;
	createXMLHttpRequest();
	xmlHttpFav.onreadystatechange = updateFavorieten;
	xmlHttpFav.open("GET", url, true);
	xmlHttpFav.send(null);
}

// doe request naar php
function addItems(itemId, aantal) {
	url = "_ajax_add_bestel_items.php?itemId="+itemId + "&aantal=" + aantal + "&" + Math.random()*9999;
	createXMLHttpRequest();
	xmlHttpFav.onreadystatechange = updateFavorieten;
	xmlHttpFav.open("GET", url, true);
	xmlHttpFav.send(null);
}

// doe request naar php
function delItems(itemId) {
	url = "_ajax_del_bestel_items.php?itemId=" + itemId + "&"  + Math.random()*9999;
	createXMLHttpRequest();
	xmlHttpFav.onreadystatechange = updateFavorieten;
	xmlHttpFav.open("GET", url, true);
	xmlHttpFav.send(null);
}

// als er eem state change is, dan tekst kader updaten
function updateFavorieten() {
	if( xmlHttpFav.readyState == 4) {
		if( xmlHttpFav.status == 200) {
			responseText =  xmlHttpFav.responseText;
			document.getElementById("divBestelOVZ").innerHTML = responseText; //ook voor ff
		}
	}
}

