    var http_request = false;


function test(){
	
//This is all nonsense for Internet explorer to do its thing

	for(i = 0; i < 200000; i++){
		x = 17 * i;	
	}
	
	if ("zap" == "tra"){

	}
	//document.bgColor = "#EF0000";
}

// we need to do big and small again

    function toggleCart(myLink,id) {
		//alert("toggling");
		//alert(currentImage.getAttribute("inCart"));
		//alert(document.getElementById("cartButton" + id));
		var currentImage = document.getElementById("cartButton" + id);
		//alert(currentImage.getAttribute("src"));	
		
		if(currentImage.getAttribute("inCart") == "false"){
			
//If it's already in cart, we need to remove it and set the picture to add
			currentImage.setAttribute("inCart","true");
			url = "/shoppingCart/shoppingCartReceiver.cfm?productID=" + id + "&amount=1";
			currentImage.src = "images/inCart.gif";
			
			httpUpdate(url);
		} else {

			currentImage.setAttribute("inCart","false");	
			currentImage.src = "images/addToCart.gif";
			removeFromCart(id);	
			
		}
		//alert('My apologies for the inconvenience.  The PayPal system will be up and running on Friday, April 28th.\nYou can still purchase CDs via the mail. Please send a cheque for your purchases @ $15.99 per CD in $USD plus $4.01 shipping for a total of $20.00 $USD per CD to:\n\nRoman Hurko\n580 Christie Street\nApt. 1207\nToronto, Ontario\nM6G 3E3\nCANADA\n\nInclude your mailing address and the titles of the CDs you are ordering.\n\nSubscribe to my Music News and I will keep you up to date with the latest news about my music and when the PayPal system is running so you can download music.\n\nThank you for your patience.\n\nChrist is Risen! Xpuctoc Bockpec!\n\nRoman Hurko');	
		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('The Ajax backend is not responding ... please contact the site administrator');
			//window.document.getElementById('scratch').value += "\nTHERE WAS A PROBLEM " + http_request.statusText;
            }
        }

    }
