			var divId ;
			var popupObj;
			var hrefToUse ;
			var productPopupObj;

//			function addToCart( itemToAdd, qtyToAdd, thisDiv, thisPopupObj )
			function addToCart( itemToAdd, qtyToAdd, thisHref, thisProductPopupObj, buyOrRent, whatFormat, linkBack )
			{

				if (typeof linkBack == "undefined") {
				    linkBack = "";
				}

				if (typeof buyOrRent == "undefined") {
				    buyOrRent = "B";
				}

				if (typeof whatFormat == "undefined") {
				    whatFormat = "";
				}


			    if ( qtyToAdd == 0 )
			    {			
			        alert( "Please Enter a Qty" ) ;
			    }
			    else
			    {				
				    hrefToUse = thisHref ;
				    productPopupObj = thisProductPopupObj;

    // force the dropdown cart to reload
				    dropDownCartLoaded = false;

    //				divId = thisDiv;
    //				popupObj = thisPopupObj ;
				    loadXMLDocAddToCart("\/ajaxAddToCart.cwa?item1=" +itemToAdd + "&qty1=" + qtyToAdd + "&type1=" + buyOrRent + "&format1=" + whatFormat + "&linkback1=" + linkBack);
				}
			}
	
			var req;

			function loadXMLDocAddToCart(url) 
			{
				url += "&ms=" + new Date().getTime();
				// branch for native XMLHttpRequest object
    				if (window.XMLHttpRequest) {
        				req = new XMLHttpRequest();
        				req.onreadystatechange = processReqChangeAddToCart;
        				req.open("get", url, true);
	        			req.send(null);
    				// branch for IE/Windows ActiveX version
    				} else if (window.ActiveXObject) {
        				req = new ActiveXObject("Microsoft.XMLHTTP");
        				if (req) {
            					req.onreadystatechange = processReqChangeAddToCart;
	            				req.open("GET", url, true);
        	    				req.send();
        				}
    				}
			}

			function processReqChangeAddToCart() 
			{
	

    				// only if req shows "complete"
				if (req.readyState == 4) {

					// only if "OK"
        				if (req.status == 200) {



						var doc = req.responseXML;   // assign the XML file to a var
					
			//			alert(doc.getElementsByTagName('dropdownhtml')[0]);
						document.getElementById("cartPopupDiv").innerHTML = doc.getElementsByTagName('additemhtml')[0].firstChild.nodeValue ;
//						document.getElementById(divId).innerHTML = doc.getElementsByTagName('additemhtml')[0].firstChild.nodeValue ;

						addToCartPopup.showPopup( hrefToUse );
// write cart item count to header
						var cartItems = doc.getElementsByTagName('itemcount')[0].firstChild.nodeValue ;
						document.getElementById("cartlink").innerHTML = "My Cart: " + cartItems + " item" + ( cartItems == "1" ? "" : "s" ) ;
//						alert(cartItems);

		       			} else {
      						alert("There was a problem retrieving the XML data:\n" + req.statusText);
						}
   				}

			}
