function JS_addtocart(uid, pcount, id, action) {
var xmlhttp;
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				xmlhttp = false;
			}
		}
	}
	if(action !='del') {
		document.getElementById('card').style.height = '80px';
	}
	document.getElementById('card').innerHTML = "<div class=\"loading\">Пожалуйста, ждите...</div>";
	if (xmlhttp) {
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				if (xmlhttp.status == 200) {
				document.getElementById('card').innerHTML ='&nbsp;';
				document.getElementById('card').innerHTML = xmlhttp.responseText;
				if (xmlhttp.responseText !='<p>Cart is empty.</p>') {
					document.getElementById('card').style.display="block";
				} else if(xmlhttp.responseText == '<p>Cart is empty.</p>') {
					document.getElementById('card').style.display="none";
				}
				}
			}
		}
		if(!action) {action = 'add';}
		xmlhttp.open("GET", "/application/controllers/ajax/addtocard.php" + "?uid=" + uid + '&pid=' + id + '&pcount=' + pcount + '&action=' + action);
		xmlhttp.send(null);
	}
}
