function getXmlHttpRequestObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); //Not IE
	} else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} else {
		//Display your error message here. 
		//and inform the user they might want to upgrade
		//their browser.
		alert("Necesita actualizar la versión de su navegador.");
	}
}

function SumaCarrito(IdProducto, Referencia, Cantidad) 
{
	var mensaje 	= "";
	var consulta 	= "suma_carrito.php?id=" + IdProducto + "&cantidad=" + Cantidad;

	var request 	= getXmlHttpRequestObject();
	request.open("GET", consulta, true);
	request.onreadystatechange = function() {

		if (request.readyState == 4) {
			mensaje = "AÑADIDO AL CARRITO\n\nRef. " + Referencia + " x " + Cantidad + " ud.";
			alert (mensaje);
			window.location.reload();
		}

	}
	request.send(null);  	

}

function RestaCarrito(IdProducto, Referencia, Cantidad) 
{
	var mensaje 	= "";
	var consulta 	= "resta_carrito.php?id=" + IdProducto + "&cantidad=" + Cantidad;

	var request 	= getXmlHttpRequestObject();
	request.open("GET", consulta, true);
	request.onreadystatechange = function() {
		
		if (request.readyState == 4) {
			mensaje = "RESTADO DEL CARRITO\n\nRef. " + Referencia + " x " + Cantidad + " ud.";
			alert (mensaje);
			window.location.reload();
		}
		
	}
	request.send(null);  	
}

function QuitaLineaCarrito(IdProducto) 
{
	var mensaje 	= "";
	var consulta 	= "quita_carrito.php?id=" + IdProducto;

	var request 	= getXmlHttpRequestObject();
	request.open("GET", consulta, true);
	request.onreadystatechange = function() {
	if (request.readyState == 4) {
			mensaje = "ELIMINADO DEL CARRITO";
			alert (mensaje);
			window.location.reload();
		}
	}
	request.send(null);  	
}
