

function UpdateCart(qty, lineid, invtid, perstype, canmust, setupchg, peritemchg, extitem, sellinmult, minorderqty, qualflag, persid, lanyardtype)
{
	//have to get the new item qty
	AddToCart(document.all("LID_" + lineid).value, lineid, invtid, perstype, canmust, setupchg, peritemchg, extitem, sellinmult, minorderqty, qualflag, persid, lanyardtype, "", "CARTUPDATE")
}

function AddToCart(qty, lineid, invtid, perstype, canmust, setupchg, peritemchg, extitem, sellinmult, minorderqty, qualflag, persid, lanyardtype, returnto, returnwhere)
{

	//redirect to lanyards
	if(lanyardtype != "" && returnwhere != "CARTUPDATE")
	{
		window.location = "/LWizard_Step2.aspx?t=" + lanyardtype + "&invtid=" + invtid + "&pid=" + persid;
		return;
	}

	//gets the text box qty if there is one, otherwise uses the passed in qty	
	if (document.form1.tbxQty)
	{qty = document.form1.tbxQty.value}

	//will add more to handle customization, rules, etc.
	
	//less than minimum
	if (parseInt(qty) < parseInt(minorderqty) && parseInt(qty) != 0)
	{
		alert("The quantity you entered is less than the minimum order quantity of " + minorderqty + ".  The quantity was updated automatically.");
		qty = minorderqty;
	}

	//not multiple of sellqty
	if (parseInt(qty) % sellinmult != 0)
	{
		alert("The quantity you entered is not an even multiple of " + minorderqty + ".  The quantity was updated automatically.");
		if (isNaN(qty))
		{qty = 1}
		
		qty = (Math.floor(parseInt(qty) / sellinmult) + 1) * sellinmult;
	}
	
	
	window.location = "/addtocart.aspx?qty=" + qty + "&invtid=" + invtid + "&lid=" + lineid + "&pid=" + persid + "&rtn=" + returnto + "&rtnw=" + returnwhere
}


function ConfirmDelete(qty, lineid, strMode)
{
	if(confirm("Click 'OK' if you want to delete this item from your shopping cart"))
		window.location = "/addtocart.aspx?qty=0&lid=" + lineid + "&dlg=" + strMode
}
