function giveTreat( animalId, updateId, countTreatsId, tok) {
	if (!tok || tok.length < 1) {
		return;
	}
	req = hex_hmac_md5(animalId, tok);
	ajaxRequest('/submit.php', 'ajax=1&command=addTreat&animalId=' + animalId + '&updateId=' + updateId + '&countTreatsId=' + countTreatsId + '&tok=' + req, 'updateTreat', false);
}

function updateTreat(xmlDoc) {
	var testLoggedIn = xmlDoc.documentElement.getElementsByTagName('notLoggedIn');
	
	if (testLoggedIn.length > 0) {
	//alert(testLoggedIn.length) ; 
		window.location = "/?page=login";	
	} else {
		var toReplace = xmlDoc.getElementsByTagName('updateId');
		if (toReplace.length == 0) return;
		var elementId = toReplace[0].firstChild.nodeValue;
		var elementToUpdate = $(elementId);
		elementToUpdate.className = 'treat_given';
		var toUpdate = xmlDoc.getElementsByTagName('countTreatsId');
		elementId = toUpdate[0].firstChild.nodeValue;
		elementToUpdate = $(elementId);
		elementToUpdate.innerHTML = parseInt(elementToUpdate.firstChild.nodeValue) + 1;
	}
}
