function addCart(id, mode) {

	var http_request = initAjax();

	http_request.onreadystatechange = function() { updateForm(http_request); }

	var url;
	url = '/updatecart.php?id=' + id + '&mode=' + mode;

	http_request.open('GET', url, true);
	http_request.send(null);

}


function emptyCart() {

	var http_request = initAjax();

	http_request.onreadystatechange = function() { refreshCart(http_request); }

	var url = '/emptycart.php?mode=empty';

	http_request.open('GET', url, true);
	http_request.send(null);

}


function updateForm(http_request) {

	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
		var action = http_request.responseText;
		eval(action);
		document.body.style.cursor = 'default';
		} else {
		alert('There was a problem with the request.');
		}
	}
	else if(http_request.readyState == 1){
		document.body.style.cursor = 'progress';
	}

}


function refreshCart(http_request) {

	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			location.reload(true);
		} else {
			alert('There was a problem with the request.');
		}
	}
	else if(http_request.readyState == 1){
		document.body.style.cursor = 'progress';
	}

}
