function drinkUpdateCallback(xmlData)
{
	var root = xmlData.getElementsByTagName('root').item(0);
		
	// Process the print history
	var results = root.getElementsByTagName('result');//[0].firstChild.data;

	for (var i = 0; i < results.length; i++)
	{
		var drinkid = results[i].getElementsByTagName('drinkid')[0].firstChild.data;
		var stock = results[i].getElementsByTagName('stock')[0].firstChild.data;
		
		document.getElementById("drinkstock" + drinkid).value = stock;

		// Hide the working image
		document.getElementById("workingimg" + drinkid).style.visibility = "hidden";
	}
	
}

function submitDrinkPurchase(drinkId, lanNum)
{
	// Show the working image
	document.getElementById("workingimg" + drinkId).style.visibility = "visible";
	
	/* Set up the request */
	var xmlhttp =  new XMLHttpRequest();
	xmlhttp.open('POST', 'index.cgi', true);
	
	/* The callback function */
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200)
				drinkUpdateCallback(xmlhttp.responseXML);
			//else
				//target.submit();
		}
	}
	
	/* Send the POST request */
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send('section=ajax&item=drinks&action=drinksold&drinkid=' + drinkId + '&lannum=' + lanNum);
}