    var http_request = false;

// we need to do big and small again

    function toggleCart(myLink,id) {
		//alert("toggling");
		//alert(currentImage.getAttribute("inCart"));
		//alert(document.getElementById("cartButton" + id));
		var inCartImage = document.getElementById("cartButton" + id + "_in");
		var addToCartImage = document.getElementById("cartButton" + id + "_out");
		//alert(currentImage.getAttribute("src"));	
		//alert(inCartImage.getAttribute("inCart"));
		if(inCartImage.getAttribute("inCart") == "false"){
			//If it's already in cart, we need to remove it and set the picture to add
			url = "/shoppingCart/shoppingCartReceiver.cfm?productID=" + id + "&amount=1";
			httpUpdate(url);

			inCartImage.setAttribute("inCart","true");
			inCartImage.style.display = "";
			addToCartImage.style.display = "none";
		} else {
			removeFromCart(id);			

			inCartImage.setAttribute("inCart","false");	
			inCartImage.style.display = "none";
			addToCartImage.style.display = "";
			
		}
		//test();
/*
		
		alert(myLink.innerHTML);
		var removeText = "<IMG src=\"/images/alreadyInCart.gif\" border=\"0\">"
		if(myLink.innerHTML != removeText){
		//alert('slapping in cart!');
		myLink.innerHTML = removeText;
		
		

		} else {
		//alert('removing');
		myLink.innerHTML = "<img border='0'  src='/images/addToCart.jpg'>";
		removeFromCart(id);
		}
		//window.document.getElementById('URL').innerHTML = url;
        //alert("test2");
		httpUpdate(url);*/
		
	}


	function removeFromCart(id){
		url = "/shoppingCart/shoppingCartReceiver.cfm?productID=" + id + "&amount=0";		
		httpUpdate(url);
	}


   


	function httpUpdate(url) {
		//alert('Doing an update');
//		window.document.getElementById('scratch').value += "\nHTTP Update";
		http_request = false;

		//Always add the time to the end of the URL to make it think it's as different page.
		url += "&IEIssue=" + new Date().getTime();

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
		//alert("Adding to event");
        http_request.onreadystatechange = alertContents;
        http_request.open('GET', url, true);
        http_request.send(null);
	//	window.document.getElementById('scratch').value += "\nGetting to status \n" + http_request.status;;
    }



// NOT NEEDED //

function alertContents() {
		//alert('ALERT FROM XML');
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                //alert(http_request.responseText);

            } else {
                alert('Cannot connect to server to report transaction, please try reloading the page');
			//window.document.getElementById('scratch').value += "\nTHERE WAS A PROBLEM " + http_request.statusText;
            }
        }

    }