	var product = new Object();
	product.id = 0;

	function addToCart( anchor )
	{
		ProductID = anchor.id.replace("anch","");
		product.id = ProductID;
	
		var strId = "?id=" + ProductID;
		var strAction = "&action=1";
		var strCode = "&code=" + parseInt( 1000 * Math.random() ) + parseInt( 1000 * Math.random() );
		url = "/library/code/shopping-cart-action.aspx" + strId + strAction + strCode;
	
		http = getHTTPObject();
		http.onreadystatechange = processAddToCart;
		http.open("GET", url, true);
		http.setRequestHeader("Cache-Control", "no-cache");
		http.send(null);
	}

	processAddToCart = function()
	{
		if (http.readyState == 4) {
			if( http.status == 200 ) {
				var trueResponse = http.responseText.replace("\n","");
				if( trueResponse == "OK" ) {
					if( window.opener )
						window.opener.document.location.reload(true);

					loadShoppingCart();

	                var buttonID = "btn" + product.id;
	                var button = document.getElementById(buttonID);
	                if(button)
	                {
	                    button.src = "/library/images/buttons/remove.gif";
	                    button.alt = "Remove from Cart";
	                }

	                var anchorID = "anch" + product.id;
	                var anchor = document.getElementById(anchorID);
	                if(anchor)
	                {
	                    anchor.onclick = function onclick(event) { javascript: removeFromCart(this); return false; };
	                }

					//alert( 'Added to shopping cart!!!');
				}
				else
					alert( 'Error: Could not add to shopping cart!!!');
			}
			else
				alert( 'Error: Could not add to shopping cart!!!');
		}
	}

	function removeFromCart( anchor )
	{
	    if(anchor.id)
		    ProductID = anchor.id.replace("anch","");
		else
		    ProductID = anchor;
		product.id = ProductID;
	
		var strId = "?id=" + ProductID;
		var strAction = "&action=0";
		var strCode = "&code=" + parseInt( 1000 * Math.random() ) + parseInt( 1000 * Math.random() );
		url = "/library/code/shopping-cart-action.aspx" + strId + strAction + strCode;
	
		http = getHTTPObject();
		http.onreadystatechange = processRemoveFromCart;
		http.open("GET", url, true);
		http.setRequestHeader("Cache-Control", "no-cache");
		http.send(null);
	}

	processRemoveFromCart = function()
	{
		if (http.readyState == 4) {
			if( http.status == 200 ) {
				var trueResponse = http.responseText.replace("\n","");
				if( trueResponse == "OK" ) {
					if( window.opener )
						window.opener.document.location.reload(true);

					loadShoppingCart();

	                var buttonID = "btn" + product.id;
	                var button = document.getElementById(buttonID);
	                if(button)
	                {
	                    button.src = "/library/images/buttons/add-to-cart.gif";
	                    button.alt = "Add to Cart";
	                }
	                    
	                var anchorID = "anch" + product.id;
	                var anchor = document.getElementById(anchorID);
	                if(anchor)
	                {
	                    anchor.onclick = function onclick(event) { javascript: addToCart(this); return false; };
	                }

					//alert( 'Removed from shopping cart!!!');
				}
				else
					alert( 'Error: Could not remove from shopping cart!!!');
			}
			else
				alert( 'Error: Could not remove from shopping cart!!!');
		}
	}
	
	function loadShoppingCart()
	{
	    if(document.getElementById('SidebarShoppingCart'))
	    {
            var strCode1 = "?code=" + parseInt( 1000 * Math.random() ) + parseInt( 1000 * Math.random() );
            var url1 = "/library/code/sidebar-shopping-cart-contents.aspx" + strCode1;

            http = getHTTPObject();
            http.onreadystatechange = processLoadSidebarShoppingCart;
            http.open("GET", url1, true);
            http.setRequestHeader("Cache-Control", "no-cache");
            http.send(null);
        }
        
        if(document.getElementById('ShoppingCart'))
        {
            var strCode2 = "?code=" + parseInt( 1000 * Math.random() ) + parseInt( 1000 * Math.random() );
            var url2 = "/library/code/shopping-cart-contents.aspx" + strCode2;

            http = getHTTPObject();
            http.onreadystatechange = processLoadShoppingCart;
            http.open("GET", url2, true);
            http.setRequestHeader("Cache-Control", "no-cache");
            http.send(null);
        }
	}

	processLoadSidebarShoppingCart = function()
	{
		var SidebarShoppingCart = document.getElementById('SidebarShoppingCart');
        
        if(SidebarShoppingCart)
        {
	        if (http.readyState == 4) {
		        if (http.status == 200)
			        SidebarShoppingCart.innerHTML = http.responseText;
		        else
			        SidebarShoppingCart.innerHTML = "<center><font color='red'><strong>Could not load shopping cart!!!</strong></font></center>";
	        }
		}
	}
	
	processLoadShoppingCart = function()
	{
		var ShoppingCart = document.getElementById('ShoppingCart');

        if(ShoppingCart)
        {
		    if (http.readyState == 4) {
			    if (http.status == 200)
				    ShoppingCart.innerHTML = http.responseText;
			    else
				    ShoppingCart.innerHTML = "<center><font color='red'><strong>Could not load shopping cart!!!</strong></font></center>";
		    }
		}
	}

	getHTTPObject = function()
	{
		if (typeof XMLHttpRequest != 'undefined') {
			return new XMLHttpRequest();
		} 
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
		return false;
	}

	function Popup(url,windowname,w,h,x,y)
	{
		window.open(url,windowname,"resizable=yes,toolbar=no,scrollbars=yes,menubar=no,status=no,directories=no,width="+w+",height="+h+",left="+x+",top="+y+"");
	}