function SendToBasket(theID, theName, theCost) {

var theBasket = document.getElementById("theBasket");
var theTotal = document.getElementById("total");
var theSave = document.getElementById("save");
var theStoredCost = document.getElementById("cost");
var strTemp1 = theBasket.innerHTML;
var strIDCode = theID.substr(1, 2);
var strIDNumb = theID.substr(3, 3);
var intRMRem, intRMCost;

theTotalCost = theCost + parseInt(theTotal.value);
theTotalSave = parseInt(theSave.value);
theMainCost = theCost + parseInt(theStoredCost.value);


if (strTemp1 != "") {

  if (strTemp1.match("/"+theID, "g") != null) {
    alert("This item is already in the basket!!\r\n\r\nNothing Added!!");
	  return;
  }
  else { 
	  if ((strIDCode == "RM") && (strIDNumb != "001")) {
			
      var intNumRM = strTemp1.split("*RM").length - 1;
      var intNumRM001 = strTemp1.split("*RM001").length - 1;
      
			if (intNumRM001 == 1) {
			  intNumRM -= 1;
			}
			
			intRMRem = intNumRM%3;
			
		  if (intRMRem == 2) {
			  theTotalCost -= theCost; // this is a free one
				theTotalSave += 15; // increase total saved
			}
		}
    strTemp1 = strTemp1 + "\r\n"; 
	}
} //end if strTemp != ""

theBasket.innerHTML = strTemp1+theID+" "+theName+" \u00A3"+theCost;
theTotal.value = theTotalCost.toFixed(2);
theSave.value = theTotalSave.toFixed(2);
theStoredCost.value = theMainCost.toFixed(2);

}

function OrderIt() {

}

function ClearSel() {
document.getElementById("theBasket").innerHTML = "";
document.getElementById("total").value = "0.00";
document.getElementById("save").value = "0.00";
document.getElementById("cost").value = "0.00";
}
