function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function addtocart(itemid, price) {
	parent.frtop.location = "http://www.thuongxavn.com/cgi-bin/addtocart.pl?" + itemid;
var mystr = "The item with the price of " + price + "\nhas been added to your shopping cart\.";
	alert(mystr);
}

function removeitem(itemid) {
	document.location = "http://www.thuongxavn.com/cgi-bin/removefromcart.pl?" + itemid;
}

function textFocus(form, index) {
	form.elements[index * 5-2 ].focus();
}

function recalculate(itemno) {
var total = 0;
var i;
	for (i=1; i<=itemno; i++ ) {
		total += parseFloat(document.chkout.elements[i*5 - 1].value);
	}
	document.chkout.txtsubtotal.value = round_off(total);
}

function updatevalue(price, txtqty, txtamount, itemno, itemid)  {
if (txtqty.value == 0) {
	var answer;
	answer=confirm("Do you want to remove this item?");
	if (answer) {
		document.location = "http://www.thuongxavn.com/cgi-bin/removefromcart.pl?" + itemid;
		document.location = "http://www.thuongxavn.com/cgi-bin/newcart.pl";
	} else {
		txtqty.value = 1;
	}
}
var quantity;
	quantity = txtqty.value;
	txtamount.value = round_off(price * quantity); //update amount
	recalculate(itemno);
}

function payonline() {
	if (document.chkout.txtsubtotal.value == 0 ) {
		alert("At least one product must be choosen!");
		return false;
	} else {
		document.chkout.action = "https://secure.vnisoft.net/cgi-bin/txvn/ccard.pl?thuongxa";
		return true;
	}
}

function paybyphone() {
	if (document.chkout.txtsubtotal.value == 0 ) {
		alert("At least one product must be choosen!");
		return false;
	} else {
		document.chkout.action = "http://www.thuongxavn.com/cgi-bin/paybyphone.pl";
		return true;
	}

//	document.chkout.action = "";
//	var MySubTotal = document.chkout.txtsubtotal.value;
//	var Shipping=0;
//	if (MySubTotal <= 20) {
//		Shipping=4.95;
//	} else if (MySubTotal <= 40) {
//		Shipping=7.95;
//	} else if (MySubTotal <= 60) {
//		Shipping=9.95;
//	} else if (MySubTotal <= 80) {
//		Shipping=7.95;
//	} else if (MySubTotal <= 100) {
//		Shipping=4.95;
//	} else {
//		Shipping=0;
//	};
//	var MyTotal = parseFloat(MySubTotal) + parseFloat(Shipping);
//	var str = "Please prepare a credit card, ready to paid for the amount of \$" + MyTotal + ". This amount includes total purchase for \$" + MySubTotal + " \& shipping  handling for \$" + Shipping + ". Then call 1-800-791-7656";
//	alert(str);
}

function paybymail() {
	if (document.chkout.txtsubtotal.value == 0 ) {
		alert("At least one product must be choosen!");
		return false;
	} else {
	document.chkout.action = "http://www.thuongxavn.com/cgi-bin/paybymail.pl";
		return true;
	}
//	document.chkout.action = "";
//	var MySubTotal = document.chkout.txtsubtotal.value;
//	var Shipping=0;
//	if (MySubTotal <= 20) {
//		Shipping=4.95;
//	} else if (MySubTotal <= 40) {
//		Shipping=7.95;
//	} else if (MySubTotal <= 60) {
//		Shipping=9.95;
//	} else if (MySubTotal <= 80) {
//		Shipping=7.95;
//	} else if (MySubTotal <= 100) {
//		Shipping=4.95;
//	} else {
//		Shipping=0;
//	};
//	var MyTotal = parseFloat(MySubTotal) + parseFloat(Shipping);
//	var str = "Please print this page and make a check payable to VNI Company with the amount of \$" + MyTotal + ". This amount includes total purchase for \$" + MySubTotal + " \& shipping handling for \$" + Shipping + ". Then mail to VNI Company 14091 Goldenwest St. Westminter, CA 92683, U.S.A.";
//	alert(str);
}

function round_off(n) {
	return Math.round(n*100) / 100;
}

