function removeItem(idx) {
  if(confirm('Are you sure you want to remove this item?'))
    document.location.href=BASE_URL+'order.delete.'+idx;
}
function updateCart() {
  document.location.href=BASE_URL+'order.update';
}
function UpdatePrices() { 
  var totalPrice = 0;
  country = document.getElementById('country');
  c = country.options[country.selectedIndex].value;
  if(c=='AUS') {
   r='AUS';
  } else {
   r='INT';
  }  
  for(i=0;i<loops;i++) {
    var type = ById('idproduct'+i);
    if(type.value != 0) {
      var qty = ById('quantity'+i);
      var quantity = parseInt(qty.value) == 0 || isNaN(parseInt(qty.value)) ? 1 : parseInt(qty.value);
      qty.value = quantity;
      var sub = ById('subtotal'+i);
      alert(type.value);
      var stotal = quantity*prices[type.value][r];
      totalPrice += stotal;
      sub.innerHTML = '$'+NicePrice(stotal);
    } else {
      var sub = ById('subtotal'+i);
      sub.innerHTML = '$'+NicePrice(0);
    }
  }
   atotal = ById('total');
   atotal.innerHTML = '$'+NicePrice(totalPrice);
}


function NicePrice(price) { 
  var decimals=2;
  price=Math.round(price*Math.pow(10,decimals))/Math.pow(10,decimals);
  price=price.toString();
  var dp=price.indexOf('.');
  if (dp==-1) {
    places=0;
    price+=(decimals>0) ? '.' : '';
  }
  else
    places=price.length-dp-1;
  pad=decimals-places;
  if (pad>0)
    for (iDecimals=0; iDecimals<pad; iDecimals++)
      price+='0';
  return price;
}

function ById(id) {
  return (document.getElementById && document.getElementById(id)) ? document.getElementById(id) : false;
}
