function checkMinQty(form,location) {
	var enough = false;
	var qty = parseInt(form.qty.value);
	
	if (location == 'USA' || location == 'CAN')
		 var min = form.am_min_qty.value;
	else
		 var min = form.eu_min_qty.value;
	
	if (qty >= min)
		 enough = true;
	else {
  	var qtyLookup = getXmlHttpObject();
  	var params = '?product_id='+form.product_id.value;
  	//qtyLookup.onreadystatechange=function(){handleQtyCheck(qtyLookup,catalog_id);}
  	qtyLookup.open("GET",'/shop/qtyLookup.php'+params,false);
  	qtyLookup.send(null);
  	var cur_amt = parseInt(qtyLookup.responseText);
		amt = qty+cur_amt;
  	if (qty+cur_amt >= min)
			 enough = true;
		else
			 enough = false;
	}
	if (enough)
		return true;
	else {
		alert('You must order a minimum of '+min+' of this product.');
		return false; 
	}
}

function checkoutMinQty(quantity,location) {
	var enough = false;
	var qty = parseInt(quantity.value);
	
	if (location == 'USA' || location == 'CAN')
		 var min = returnObjById('am_min_qty').value;
	else
		 var min = returnObjById('eu_min_qty').value;
	
	if (qty >= min)
		 enough = true;
	else {
  	var qtyLookup = getXmlHttpObject();
  	var params = '?product_id='+qty.id;
  	//qtyLookup.onreadystatechange=function(){handleQtyCheck(qtyLookup,catalog_id);}
  	qtyLookup.open("GET",'/shop/qtyLookup.php'+params,false);
  	qtyLookup.send(null);
  	var cur_amt = parseInt(qtyLookup.responseText);
		amt = qty+cur_amt;
  	if (qty+cur_amt >= min)
			 enough = true;
		else
			 enough = false;
	}
	if (enough)
		return true;
	else {
		alert('You must order a minimum of '+min+' of this product.');
		quantity.value = min;
		return false; 
	}
}

function getXmlHttpObject() {
	var xmlHttp;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  return xmlHttp;
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    try
	      {
	      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	      }
	    catch (e)
	      {
	      alert("Your browser is out of date and will not display this site. Please upgrade to a newer browser in order to continue.");
	      return false;
	      }
	    }
	  }
	  return xmlHttp;
}
