<!--
function cal(submit)
{
	//h = high  , e = easy , l = low

	var h_qty0 = e_qty0 = l_qty0 = l_qty1 = l_qty2 = l_qty3 = l_qty4 = l_qty5 = h_subt = e_subt = l_subt = h_total_qty = e_total_qty = l_total_qty = 0;

	if(document.form1.h_qty0.value)
		h_qty0 = parseInt(document.form1.h_qty0.value);

	if(document.form1.e_qty0.value)
		e_qty0 = parseInt(document.form1.e_qty0.value);

	if(document.form1.l_qty0.value)
		l_qty0 = parseInt(document.form1.l_qty0.value);
	if(document.form1.l_qty1.value)
		l_qty1 = parseInt(document.form1.l_qty1.value);
	if(document.form1.l_qty2.value)
		l_qty2 = parseInt(document.form1.l_qty2.value);
	if(document.form1.l_qty3.value)
		l_qty3 = parseInt(document.form1.l_qty3.value);
	if(document.form1.l_qty4.value)
		l_qty4 = parseInt(document.form1.l_qty4.value);
	if(document.form1.l_qty5.value)
		l_qty5 = parseInt(document.form1.l_qty5.value);

	h_total_qty = h_qty0;
	e_total_qty = e_qty0;
	l_total_qty = l_qty0 + l_qty1 + l_qty2 + l_qty3 + l_qty4 + l_qty5;

	h_subt = h_total_qty * 15;
	e_subt = e_total_qty * 10;
	l_subt = (l_qty0*20) + (l_qty1*20) + (l_qty2*20) + (l_qty3*20) + (l_qty4*20) + (l_qty5*5);
	
	total_qty = h_total_qty + e_total_qty + l_total_qty;//sum total quantity all card
	total_subt = h_subt + e_subt + l_subt;
	
	var h_comm = e_comm = l_comm = 0; //commission for low profit is up to quantity

	//high commission when sub total more than 500 or qty of high comm. more than 35 then more commission
	if(total_subt >= 250 && total_subt < 600)
		h_comm = 0.35;
	else if(total_subt >= 600)
		h_comm = 0.45;

	//easy commission
	if(total_subt >= 250 && total_subt < 600)
		e_comm = 0.20;
	else if(total_subt >= 600 && total_subt < 1000)
		e_comm = 0.25;
	else if(total_subt >= 1000 && total_subt < 2000)
		e_comm = 0.28;
	else if(total_subt >= 2000)
		e_comm = 0.3;

	//low commission
	if(total_subt >= 250 && total_subt < 600)
		l_comm = 0.20;
	else if(total_subt >= 600 && total_subt < 1000)
		l_comm = 0.25;
	else if(total_subt >= 1000 && total_subt < 2000)
		l_comm = 0.28;
	else if(total_subt >= 2000)
		l_comm = 0.3;

	//alert('High '+h_comm +' Easy '+e_comm + ' Low '+l_comm + ' Total '+total_subt);

	var h_subt = h_dis = h_total = l_subt = l_dis = l_total = e_subt = e_dis = e_total = 0;

	if(h_total_qty)
	{
		var h_subt = 15 * h_total_qty;
		var h_dis = h_comm * ( 15 * h_total_qty );
		var h_total = h_subt - h_dis;
	}
	if(e_total_qty)
	{
		var e_subt = 10 * e_total_qty;
		var e_dis = e_comm * ( 10 * e_total_qty );
		var e_total = e_subt - e_dis;
	}
	if(l_total_qty)
	{
		var l_subt = (l_qty0*20) + (l_qty1*20) + (l_qty2*20) + (l_qty3*20) + (l_qty4*20) + (l_qty5*5);
		var l_dis = l_comm * ( (l_qty0*20) + (l_qty1*20) + (l_qty2*20) + (l_qty3*20) + (l_qty4*20) + (l_qty5*5) );
		var l_total = l_subt - l_dis;
	}

	var subt = h_subt + e_subt + l_subt;
	var dis = h_dis + e_dis + l_dis;//profits is discount volume
	var total = h_total + e_total + l_total;
	
	if(document.form1.shipping.value=="regular")
	{
		//Free Shipping if you order before May 31, 2002)
		total_plus_ship = total + 0;
		ship_costs = 0;
	}
	if(document.form1.shipping.value=="express")
	{
		total_plus_ship = total + 15;
		ship_costs = 15;
	}
	if(document.form1.shipping.value=="free")
	{
		total_plus_ship = total + 0;
		ship_costs = 0;
	}

	//display in the text box
	document.form1.total_qty.value = total_qty;//display total qty.

	document.form1.retail_price.value = round(subt,2);
	document.form1.reseller_discount.value = round(dis,2);
	document.form1.ship_costs.value = round(ship_costs,2);
	document.form1.total_payment.value = round(total_plus_ship,2);
	
	document.form1.total_income.value = round(subt,2);
	document.form1.product_costs.value = round(total,2);
	document.form1.profits.value = round(dis,2);
	
	var all = ( dis * 100 )/total;//cal return investment discount per investment in percent
	document.form1.all.value = round(all,2);

	if(submit)
	{
		if(total_subt < 250)
		{
			alert("Minimun order must be $250");
			return false;
		}
		if(document.form1.method_payment.value == "")
		{
			alert("Method of Payment is Required");
			document.form1.method_payment.focus();
			return false;
		}
		if((document.form1.shipping.value == "" || document.form1.shipping.value == "free") && total_qty > 30)
		{
			alert("Shipping is Required");
			document.form1.shipping.focus();
			return false;
		}
		if(document.form1.method_payment.value == "creditcard" && total_subt > 2000)
		{
			alert("If pay by credit card, maximum order is $2000.");
			document.form1.method_payment.focus();
			return false;
		}
	}
	return true;
}
// -->