function constructAddToShoppingCartAJAX(oriObject) {
  //remember the rowID because when the AJAX call returns, 
  //it must be able to find the label
	basketID = rowID;
  
  qtyRow = document.getElementById("qty_" + rowID);
  itemRow = document.getElementById("row_" + rowID);
  custIdRow = getEl("custId_" + rowID);
  
  if (qtyRow == null || itemRow == null) {	
	  basketID = rowOrderID;
  
		qtyRow = document.getElementById("orderrow_qty_" + rowOrderID);
		itemRow = document.getElementById("orderrow_" + rowOrderID);
	}
	
	if (qtyRow != null && itemRow != null) {
    var inputVal = oriObject.value.valueOf() * 1;
    var sellVal = qtyRow.getAttribute("name").valueOf() * 1;
    var itemCode = itemRow.getAttribute("name");
    
    if (inputVal == 0) {
      sendAddToShoppingCartAJAX(itemCode, inputVal);
      return true;
    }
    
    if (inputVal >= sellVal && inputVal % sellVal == 0) {
      //add the value to the cart      
      sendAddToShoppingCartAJAX(itemCode, inputVal);
      return true;
    }
    else {
      if (sellVal == 3000) {
        if (inputVal % 250 == 0) {
          message = "The standard order quantity for custom printed labels is 3,000 and multiples thereof. \r\n"+
            "However special quantity multiples exist for non-pictorial labels such as \r\n"+
            "Descriptive Labels (250) and Point of Sale items such as posters and wobblers (500)";
          alert(message);
          sendAddToShoppingCartAJAX(itemCode, inputVal);
          return true;
        }
        else {
          message = "The standard order quantity for custom printed labels is 3,000 and multiples thereof. \r\n"+
            "However special quantity multiples exist for non-pictorial labels such as \r\n"+
            "Descriptive Labels (250) and Point of Sale items such as posters and wobblers (500) \r\n"+
            " \r\nPlease re-enter the quantity.";
        }
      }
      else {
        message = "These items must be ordered in multiples of " + sellVal +
          ". \r\nPlease re-enter the quantity.";
      }
      
      alert(message);
      qtyRow.innerHTML = "";
      oriObject.value = "";
      return false;
    }
  }
  return false;
}

function validateAddToShoppingCartCallback(responseStr) {
  var basketImg = document.getElementById("basket_" + history_rowid);

  if (responseStr == "insert" || responseStr == "update") {
    basketImg.innerHTML = "<img src=\"n_images/cart.gif\" style=\"padding: 0; margin: 0\"  />";
  }
  else if (responseStr == "delete") {
    if (getEl("qty_"+rowID) != null) {
      var orderQty = getEl("qty_"+rowID).innerText;
      if (orderQty != null && orderQty*1 > 0) {
        return;
      }
      
      basketImg.innerHTML = "&nbsp;";
    }
    
    if (document.getElementById("gotopage").value == "5" ||
				document.getElementById("gotopage").value == "7" ||
				document.getElementById("gotopage").value == "12" ||
				document.getElementById("gotopage").value == "13") {
			stayInCurrentPage();
		}
  }
  else if (responseStr.indexOf("error:") == 0) {
    alert(responseStr.substr(6));
    getEl("qty_"+rowID).innerHTML = "";
  }
  
  var qtyObj = document.getElementById("txtfldQty");
  qtyObj.value = "";
}
