<!--
function cal()
{
	total_qty();
	if(document.form1.total_quantity.value < 10)
	{
		alert("Quantity of phonecards is required at least 10");
		return false;
	}
	//document.write(document.form1.method_payment.value);
	if(document.form1.method_payment.value == "")
	{
		alert("Method of Payment is Required");
		return false;
	}
	if((document.form1.shipping.value == "" || document.form1.shipping.value == "free") && document.form1.total_quantity.value > 30)
	{
		alert("Shipping is Required");
		return false;
	}
	if(document.form1.method_payment.value == "creditcard" && document.form1.total_quantity.value > 120)
	{
		alert("If pay by credit card, maximum order is 120 cards.");
		return false;
	}
	//uncomment below when promotion is finished
	/*if(document.form1.total_quantity.value >= 10 && document.form1.total_quantity.value <= 30 )
	{
		document.form1.shipping.value="free";
	}*/
	var comm; //commission eg. 3% is 0.03 
	var quantity=document.form1.total_quantity.value;
/*	10-30  13.8%
	31-50  15.3%
	51-70  16.7%
	71-100  18.1%
	101-200  20%
	201 up   23.1%*/

	if(quantity >= 10 && quantity <= 30)
		comm=0.138; //commission 12 %
	if(quantity >= 31 && quantity <= 50)
		comm=0.153;
	if(quantity >= 51 && quantity <= 70)
		comm=0.167;
	if(quantity >= 71 && quantity <= 100)
		comm=0.181;
	if(quantity >= 101 && quantity <= 200)
		comm=0.20;
	if(quantity >= 201)
		comm=0.231;

	//commission minus 3 % when select credit card
	if(document.form1.method_payment.value=="creditcard")
		comm=comm-0.03;
	
	//calculate total payment when minus commission is total variable 
	var total=(20*quantity)*(1-comm);
	//calculate real cost
	var real_cost=20*quantity;
	var total_income=20*quantity;
	//calculate discount
	var discount=comm*real_cost;

	//keep total no shipping
	total_no_shipping=total;
	var profits=total_income-total_no_shipping;

	if(document.form1.shipping.value=="regular")
	{
		//Free Shipping if you order before May 31, 2002)
		total=total+0;
		ship_costs=0;
	}
	if(document.form1.shipping.value=="express")
	{
		total=total+15;
		ship_costs=15;
	}
	if(document.form1.shipping.value=="free")
	{
		total=total+0;
		ship_costs=0;
	}

	//display in the text box
	document.form1.reseller_discount.value=discount;
	document.form1.real_costs.value=real_cost;
	document.form1.ship_costs.value=ship_costs;
	document.form1.total_payment.value=total;
	document.form1.total_income.value=total_income;
	document.form1.product_costs.value=parseInt(total_no_shipping);
	document.form1.profits.value=parseInt(profits);
	
	//calculate profits in percent and display
	var all=(profits*100)/total_no_shipping;
	document.form1.all.value=parseFloat(all);

	return true;
}
function write_test()
{
	var qty_1=0;
	var qty_2=0;
	var qty_3=0;
	if(form1.quantity_1.value != "")
	{
		qty_1=parseInt(form1.quantity_1.value);
	}
	if(form1.quantity_2.value != "")
	{
		qty_2=parseInt(form1.quantity_2.value);
	}
	if(form1.quantity_3.value != "")
	{
		qty_3=parseInt(form1.quantity_3.value);
	}	
	//form1.total_quantity.value=qty_1+qty_2+qty_3;

	document.write(qty_1+qty_2+qty_3);
}
function total_qty()
{
	//document.form1.total_quantity.value="5";
	//alert ("none");
	//return true;
	var qty_1=0;
	var qty_2=0;
	var qty_3=0;
	if(document.form1.quantity_1.value != "")
	{
		qty_1=parseInt(document.form1.quantity_1.value);
	}
	/*if(document.form1.quantity_2.value != "")
	{
		qty_2=parseInt(document.form1.quantity_2.value);
	}
	if(document.form1.quantity_3.value != "")
	{
		qty_3=parseInt(document.form1.quantity_3.value);
	}*/

	//document.form1.total_quantity_2.value=qty_1+qty_2+qty_3;
	document.form1.total_quantity.value=qty_1+qty_2+qty_3;
}
// -->