var xhr; // XMLHttpRequest
var spanID = 0;
function getProduct(product_ID) {
		xhr = createXHR();
		xhr.onreadystatechange=processZipData;
		xhr.open("GET", "../Scripts/getProduct.php?product_ID="+product_ID);
		xhr.send(null);
}

function getProduct9(product_ID) {
		xhr = createXHR();
		xhr.onreadystatechange=processZipData;
		xhr.open("GET", "../Scripts/getProduct9.php?product_ID="+product_ID);
		xhr.send(null);
}



function processZipData() {
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			var res = xhr.responseText;
			document.getElementById("result").innerHTML = res;
		} else {
			document.getElementById("result").innerHTML = "Fout bij het ophalen van de data...";
		}
		document.getElementById("loader").style.display = "none";
	} else if (xhr.readyState > 1) {
		document.getElementById("loader").style.display = "inline";
	}
}

function createXHR() {
	var xhr;
	try {
		xhr = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xhr = false;
		}
	}
	if (!xhr && typeof XMLHttpRequest != 'undefined') {
		  xhr = new XMLHttpRequest();
	}
	return xhr;
}

function getAantal(aantal,orderdetail_ID) {
		xhr = createXHR();
		xhr.onreadystatechange=processZipData;
		xhr.open("GET", "../Scripts/getProduct.php?aantal="+aantal+"&orderdetail_ID="+orderdetail_ID);
		xhr.send(null);
}

function productDelete(orderdetail_ID) {
		xhr = createXHR();
		xhr.onreadystatechange=processZipData;
		xhr.open("GET", "../Scripts/getProduct.php?aantal="+0+"&orderdetail_ID="+orderdetail_ID);
		xhr.send(null);
}

function getOpmerking(opmerking,orderdetail_ID) {
		xhr = createXHR();
		xhr.onreadystatechange=processZipData;
		xhr.open("GET", "../Scripts/getProduct.php?opmerking="+opmerking+"&orderdetail_ID="+orderdetail_ID);
		xhr.send(null);
}

function radioInput(soort,orderdetail_ID) {
		xhr = createXHR();
		xhr.onreadystatechange=processZipData;
		xhr.open("GET", "../Scripts/getProduct.php?soort="+soort+"&orderdetail_ID="+orderdetail_ID);
		xhr.send(null);
}

function homebestellen(product_ID) {
	//getProduct(product_ID);
	xhr = createXHR();
	xhr.onreadystatechange=processZipData;
	xhr.open("GET", "http://www.piccolobeerse.be/Scripts/getProduct.php?product_ID="+product_ID);
	xhr.send(null);
	
	window.location="http://www.piccolobeerse.be/bestellen/bestellen.php";
}

