function cartaction(action, pid, qty) 
{
  // addtocart() - adds product to the shopping cart
  // PARAM - pid : product ID

  var Rmks = (typeof(Remarks)=='undefined') ? "" : Remarks.value;

  if (action=='ADD')
  {
    var elts = document.body.getElementsByTagName("select")
    var ThisElt = 'opt' + pid;
    var Options = '';

    for(i=0;i<elts.length;i++)
    { 
  	// If there is an option for this item, find the option value
  	if (elts[i].id.indexOf(ThisElt)>-1) 
  	{ 
  		var catid = elts[i].id.substr((elts[i].id.indexOf(ThisElt) + ThisElt.length + 1));
  		Options += "&Options[" + catid + "]=" + elts[i].value;
  	}
    }

  } else if (action=='CQTY')
  {
    var Options = ""; 
  }
  atc = new AJAX();

  atc.open("POST", "ajax_modcart.php", true);
  atc.onreadystatechange=function()
  {
    if (atc.readyState==4) 
    {
	document.getElementById("shoppingcart").innerHTML=atc.responseText;
    }
  }

  atc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  atc.send("action="+action+"&products_id="+pid+"&quantity="+qty+"&Remarks="+Rmks+Options);

}


function CReplace(elementid,content)
{
  if (document.getElementById && !document.all){
  rng = document.createRange();
  el = document.getElementById(elementid);
  rng.setStartBefore(el);
  htmlFrag = rng.createContextualFragment(content);
  while (el.hasChildNodes())
  el.removeChild(el.lastChild);
  el.appendChild(htmlFrag);
}
}
