function UpdateGSTInc(guidID) {
	//get ex cost and add 10%
	var el = document.all.item('nCostGSTEx'+guidID);
	var nEx = 0, nInc = 0;
	if (el != null) {
		nEx = el.value.replace(/\$|\,/g,'');
	}
	nInc = nEx * 1.1;
	el = document.all.item('nCostGSTInc'+guidID);
	if (el != null) el.value = FormatCurrency(nInc);
	return true;
}

function UpdateGSTEx(guidID) {
	//get inc cost and /1/11
	var el = document.all.item('nCostGSTInc'+guidID);
	var nEx = 0, nInc = 0;
	if (el != null) {
		nInc = el.value.replace(/\$|\,/g,'');
	}
	nEx = nInc - (nInc * 1/11);
	el = document.all.item('nCostGSTEx'+guidID);
	if (el != null) el.value = FormatCurrency(nEx);
	return true;
}

function FormatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num)) num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10) cents = "0" + cents;
	
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
	
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function SetMinimumOrder(elID) {
	var el = document.all.item(elID, 0);
	if (el != null) {
		if (Number(el.value) <= 0) el.value = 1;
	}
}

function EmptyCart(sURL) {
	location.href = sURL + '?bEmptyCart=1';
}
